Description: Finds the zero-based index of the first reason whose database field equals a requested value.
Calling convention: CIP_GetReasonIndexByFieldValue("ContainerName": String, "DBFieldName":String, FieldValue: Variant,["TargetObjectName": String], [TargetDataID])
Parameters:
ContainerName: reason-container entry name.
DBFieldName: reason database field to compare, including supported system fields such as DURATION, DB_REMARK or DB_REASON_ID.
FieldValue: required comparison value.
TargetObjectName: optional target object; when supplied, TargetDataID must also be supplied.
TargetDataID: optional, non-NULL target record ID used together with TargetObjectName. The function accepts exactly three or five arguments.
Returns: Zero-based reason index, or -1 when no match exists. A four-argument call is rejected with a clear error.
Availability: Default; uses the active DBForm when possible, otherwise loads the target record.
Example:
ReasonIndex := CIP_GetReasonIndexByFieldValue("Reason", "DB_REASON_ID", 15);