AddReferences
You can use the AddReferences function to create a reference relationship between an Optiva object and one or more related objects. This function links related objects and are displayed on the References tab of the target object. You can use these objects to navigate and manage relationships across different object types in Optiva.
When to use
You can use this function to:
- Create reference relationships between related Optiva objects.
- Display related objects on the References tab of an object.
- Associate multiple references with an object in a single operation.
When not to use
You cannot use this function if the specified reference type is not supported by the references functionality.
Syntax
long AddReferences(string objSymbol, string objkey, string refType, params object[] @params)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| objSymbol | string | Optional |
The symbol of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| objKey | string | Optional |
The key of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| @params [] | string | Optional |
The collection of reference identifiers that specifies the objects to associate with the source object.
Note: Each identifier must match a predefined option for the specified reference type in the Optiva enumerated list.
|
| refType | string | Optional | The type of object that is referenced. |
Return Value
The application returns a value greater than zero (0) if the operation is successful.
Impact
- The changes are displayed in Optiva user interface.
- A reciprocal reference is not created (the reference is directional from the target to the referenced objects).
Prerequisites
- The object codes or IDs passed in @params must be valid for the specified reference type.
- You must configure the reference type in the application before using this function. For example, to use
AddReferencesto reference specifications to formulas, formulas must already be configured to reference specifications. - The user must have permission to modify references for the specified object type.
- The target object specified by objSymbol and objKey, and all referenced objects specified in @params, must exist in the application.
Examples
- Example 1
-
The PIZZASAUCE\199 and PIZZASAUCE\202 specifications are referenced to the PIZZASAUCE\002 formula.
AddReferences("FORMULA", "PIZZASAUCE\002", "SPECIFICATION", "PIZZASAUCE\199", "PIZZASAUCE\202");
- Example 2
-
The PIZZASAUCE\199 and PIZZASAUCE\202 specifications are referenced to the current object of the workflow or copymethod.
AddReferences("", "", "SPECIFICATION", "PIZZASAUCE\199", "PIZZASAUCE\202");
- Example 3
-
Retrieve ITEMCODE, get referenced SPECIFICATION from the OBJECTCODE.REF.V\REFITEM3, and add the specification to the Formula References tab.
object oItem = ObjProperty("ITEMCODE", "", ""); if (oItem == null) { MessageList("No manufacturing item (ITEMCODE) assigned."); return 0; } string itemCode = (oItem is Array arr ? arr.GetValue(0).ToString() : oItem.ToString()); MessageList("Manufacturing item (ITEMCODE): " + itemCode);
- Example 4
- Copy Method example
- Example 5
- Duplicate References example