HasContextAttrib
You can use the HasContextAttrib function to check whether an Optiva object has specific context attributes assigned. The function returns the number of matching context attributes for the specified object.
When to use
You can use this function when validating if an object has required context attributes before processing.
When not to use
You cannot use this function when you need to retrieve context attribute values rather than check whether the attributes exist.
Syntax
long HasContextAttrib(string objSymbol, string objKey, string AttribName, params string[] @params)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| objSymbol | string | Yes |
The symbol of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| objKey | string | Yes |
The key of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| @params [] | string | Yes | The variable-length parameter array containing one or more attribute values to check. |
| AttribName | string | Yes | The type of context attribute.Possible values:
|
Return Value
The application returns a value zero (0) if the ContextAttrib is not assigned.
Examples
- Example 1
-
Basic Usage – Verify Item has an associated selling location.
public long wf_start() { long lSell = HasContextAttrib("ITEM", "SAUCE", "SELLOC", "ENGLAND"); if (lSell == 0) { MessageList("This item can't be sold in England. Workflow cancelled."); return 0L; } else { return 1L; } }
- Description
- This example checks that the item SAUCE has selling location ENGLAND. If not, a message is displayed to the user and the workflow is cancelled.
- Example 2
-
Verify the item is assigned to brand.
long lBrand = HasContextAttrib("", "", "C_BRAND", "ACME"); if (lBrand == 0) { long lAcme = AddContextAttrib("", "", "C_BRAND", "ACME"); }
- Description
- This example checks that the workflow object is assigned to the ACME brand. If not, the object is assigned to that brand.
- Example 3
-
Verify current object of the workflow is of PRODUCT TYPE moisturizer.
long lType = HasContextAttrib("", "", "C_PRODTYPE", "MOISTURIZER"); if (lType == 1) { long lSet = AddSetCodes("", "", "CREAMS"); }
- Description
- This example checks the product type of the workflow object. If it is a moisturizer, it is added to the CREAMS set code.