Edit

CheckCodeField (windowRef, itemID, tableName, ...)

Definition:  This function has 4 variants for the different codes that it will check. If the text field identified by windowRef+itemID contains a valid code for the named table, then the function returns true without doing anything further.

If the code is not valid, then the function will pop up the standard Choices window for that table. If the user selects a record, then the function returns true. If the user cancels, the function returns false.

Variants: 

  • CheckCodeField(windowRef, itemID, "account", boolWantDept, boolAllowDept, optionalRequiredType)
  • CheckCodeField(windowRef, itemID, "name", custType, suppType)
  • CheckCodeField(windowRef, itemID, "product", boolWantShipMeth)
  • CheckCodeField(windowRef, itemID, "job")

For "account", you can specify boolWantDept = true to require a dept code for departmentalised accounts. You can specify boolWantDept false and boolAllowDept if the field can have a departmentalised account without the department code being present. The optionalRequiredType parameter can be a two character account type code or system type code or "**" for IN/EX accounts. If no type is specified, then any type is allowed.

For "name" custType should be 0, 1 or 2 for not customers, customers or debtors, respectively. SuppType should be 0, 1 or 2 for not suppliers, suppliers or creditors, respectively. e.g. for Debtor codes only, specify CheckCodeField(windowRef, itemID, "name", 2, 0)

Use this function from a ValidateField or ValidateCell handler to validate a code in the field.

Availability:  available within MWScript handlers.

See Also:

AutoFillAcctDeptField: Apply auto-complete to a departmental account code edit field

AutoFillField: Apply auto-complete to a code edit field

ValidateFieldWithValidationString: Programmatically apply a custom validation expression to a field