project BLF > class BCustomField > method BusinessFieldValueIsInUse
Description
check if a custom business field value is already used in database records
Parameters
icCustomFieldName | input | character | |
icCustomFieldValue | input | character | |
olIsInUse | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/bcustomfield.p)
if icCustomFieldName begins "t"
then assign vcTable = substring(entry(1,icCustomFieldName,"."),2,-1,"CHARACTER").
if num-entries(icCustomFieldName,".") = 2
then assign vcField = entry (2,icCustomFieldName,".").
/* not a database table */
if vcTable begins "CustomTable"
then return.
if vcTable = ""
or vcField = ""
then do:
<M-1 run SetMessage
(input 'Invalid field name.' (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'S' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-62':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCustomField>
assign oiReturnStatus = -3.
return.
end.
if vcField begins "CustomShort"
or vcField begins "CustomCombo"
or vcField begins "CustomLong"
or vcField begins "CustomNote"
or vcField begins "QADC0"
then assign vcQuery = "for each " + vcTable + "1 where " + vcTable + "1." + vcField + " = '" + icCustomFieldValue + "'".
else assign vcQuery = "for each " + vcTable + "1 where " + vcTable + "1." + vcField + " = " + icCustomFieldValue.
<M-2 run StartPersistence (output vhFcComponent (ohPersistence),
output oiReturnStatus (oiReturnStatus)) in BCustomField>
if oiReturnStatus <> 0
then return.
<M-3 run CheckExistence
(input 'BCustomField.BusinessFieldIsInUse' (icQueryName),
input vcQuery (icPrepare),
input vcTable + '1' (icTables),
output olIsInUse (olEof),
output oiReturnStatus (oiReturnStatus)) in persistence>
if olIsInUse = ?
then olIsInUse = yes.
else olIsInUse = not olIsInUse.