ObjPropertySet
You can use the ObjPropertySet function to set the value of an Optiva field in the database. The function updates header fields or specific cells in detail tables with new values.
Note: The arguments are similar to the
ObjProperty function, with additional arguments for the new value and save mode.
When to use
You can use this function to:
- Set header field values, such as Description, Status, and custom fields.
- Modify specific cell values in detail tables.
When not to use
You cannot use this function when adding new rows to tables. Use GetNewRow and CommitNewRow or other data-specific functions, such as AddContextAttrib and AddSetCodes.
Syntax
long ObjPropertySet(string value, long saveMode, string propertyName, string objSymbol, string objectKey, string rowKey, long keycol)
Supported Method Signatures
long ObjPropertySet(string value, long saveMode, string propertyName);
long ObjPropertySet(string value, long saveMode, string propertyName, string objSymbol);
long ObjPropertySet(string value, long saveMode, string propertyName, string objSymbol, string objectKey);
long ObjPropertySet(string value, long saveMode, string propertyName, string objSymbol, string objectKey, rowKey, keyCol);
Parameters
| Parameter | Description |
|---|---|
| value | The new value to set for the Optiva field. The value can have one of these data types. Possible values:
|
| saveMode | Use 1 or 0 as the placeholder.
Note: This parameter exists only for backward compatibility with older versions and has no function
. |
propertyName |
The name of the field to update.
Note: Follow the same steps described for ObjProperty to derive the propertyName of the attribute.
|
| objSymbol |
The symbol of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| objKey |
The key of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| rowKey | The key for the row where the value exists in table data. The function updates data in an existing table row.
Note: Unlike ObjProperty, ObjPropertySet cannot set data for an entire column.
|
| keycol | Required when a rowKey is specified to update table data. |
- Determining the Correct ColumnKey
-
- The column key is the DB_FIELD_NAME in the Validation form or table for the column that holds the rowKey value.
Note: You must not use the field name of the column.
- You can optionally use the FIELD_NO of the reference column, usually DEP_FIELD_NO, divided by 100.
- Using DB_FIELD_NAME reduces the possibility of changes over time or copy-and-paste errors from another source.
- You can use any appropriate column for rowKey and keycol.
- You can also use ITEMCODE or PARAMCODE directly as the keycol argument.
Note:- When working with tables,
ObjPropertySetcan update only existing table row data. - The function cannot add a new row to a table. See Dataset Objects.
- The column key is the DB_FIELD_NAME in the Validation form or table for the column that holds the rowKey value.
Return Value
he application returns a value greater than zero (0) if the operation is successful.
Impact
- The function modifies the field value in the database immediately.
- The changes are persisted and visible to all users.
Prerequisites
- The value needs to conform to the field data type and validation rules.
- The function cannot add new rows to tables. The function updates existing rows only.
- The row needs to exist when updating table cells.
- The key column needs to identify the target row correctly.
Examples
- Example 1
-
Set the header description for current object.
ObjPropertySet("new description set from scripting", 1L, "DESCRIPTION");
- Parameter details:
-
- Value:new description set from scripting.
- SaveMode: 1
- PropertyName: DESCRIPTION
- Symbol: "" (Current Symbol)
- Object: "" (Current Object)
- Example 2
-
Set the Component type(drop-down) of an Item to 'Raw Material'
ObjPropertySet(8, 1L, "COMPONENTIND");
- Parameter details:
-
- Value: 8
- SaveMode: 1
- PropertyName: COMPONENTIND
- Symbol: "" (Current Symbol)
- Object: "" (Current Object)
The component type enumeration codes are:Enum Codes Component Type 1 Material 2 Packaging 3 Process aid, discrete 4 Process aid, material 5 Process (future) 6 Instruction 7 Packaging Assembly 8 Raw material 9 Grouping set 10 Overhead cost (future)
- Example 2.1
-
Set the UOM of an item to kg.
ObjPropertySet("KG", 1L, "UOMCODE");
- Example 2.2
-
Set the class of any object to default.
ObjPropertySet("DEFAULT", 1L, "CLASS", "", "");
- Parameter details:
-
- Value - DEFAULT (Class name)
- SaveMode - 1
- PropertyName - CLASS
- Symbol - "" (Current Symbol)
- Object – "" (Current Object)
- Example 3
-
Set the value of parameter SODIUM to 22 for the formula REPL\0001 object.
ObjPropertySet(22, 1L, "VALUE.TPALL", "FORMULA", "REPL\0001", "SODIUM", PARAM_CODE);
- Parameter details:
-
- Value - 22
- SaveMode - 1
- PropertyName - VALUE.TPALL
- Symbol – FORMULA
- Object – REPL/0001
- keycol - PARAM_CODE ("SODIUM" appears in the "PARAM_CODE" column of the table)
- Example 4
-
Set the amount of an ingredient, ITEM01, in any formula.
ObjPropertySet(2.43, 0, "QUANTITY.INGR.A", "", "", "ITEM01", "ITEMCODE");
- Parameter details:
-
- Deriving PropertyName : QUANTITY.INGR.A
- Format : FIELD_NAME.INGR.VALIDATION_RECFMT
Let us frame the propertyName by following the below process.
- DTLCODE can be found in the object specific objectdtlinfo table.
- INGR is the detail code for Item lines tab in FORMULA.
- As per objectdtlinfo (For FORMULA), G.FORMINGRED is the VALID_CODE.
- Parameter details:
-
- Value - 2.43
- SaveMode - 0
- PropertyName - QUANTITY.INGR
- Symbol - "" ->Current symbol of the workflow
- rowKey - ITEM01
- keycol - ITEM_CODE (ITEM_CODE is the column that contains the Item ITEM01).
- Example 5
-
Add an MFG item to the formula to transform it into a master formula.
//Adding a Manufacturing Item IT1 in the current workflow formula. ObjPropertySet("IT1", 1L, "ITEMCODE"); //Enable the Master Formula checkbox - PRIMARYFORMULAIND is the FIELD_NAME of Master Formula checkbox,as per the FSVALIDATIONFIELD table. ObjPropertySet(1, 1L, "PRIMARYFORMULAIND", "", "");
Note:To make a formula a master formula, you must add an MFG item.
- Example 6
-
Enter Approval Code in any Formula.
ObjPropertySet(100, 0, "APPROVALCODE.STATUS"); // Value to set - 100
- Example 7
-
Add text for any DOCCODE in the Notes tab for any object.
ObjPropertySet("Instruction Text from WF", 0, "DOCTEXT.DOC", "", "", "INSTRUC", "FUNCTION_CODE");
Note: When updating the document text for any document code, use the FUNCTION_CODE as the col key, as defined in the FSDOC table. Review the Symbol form for the current object to check for the exact spelling of available Function Codes.
- Example 8
-
Set rule codes (Degradation Rule, Parameter Rounding Rule, Daily Value Rule) and serving size in Analysis form.
ObjPropertySet("DVR_RULE", 0, "RULEDEGRADATION", "", ""); ObjPropertySet("RDV_RULE", 0, "RULEDAILYVALUE", "", ""); ObjPropertySet("RR_RULE", 0, "RULEROUNDING", "", ""); ObjPropertySet(2, 0, "SERVINGSIZE", "", "");
Note: The FIELD_NAMEs of Degradation Rule, Parameter Rounding Rule, Daily Value Rule and Serving size are RULEDEGRADATION, RULEROUNDING, RULEDAILYVALUE and SERVINGSIZE respectively.
- Example 9
-
Set The Reference status for a Vendor ACME on the current item to "Active".
ObjPropertySet("CURRENT", 1, "REFSTATUS.REF.V\REFITEM1", "", "", "ACME", "OBJECTCODE");
The example sets the reference status for vendor ACME on the current item to active.
- Check the V\REFITEM Lookup Set to find the lookup code for the Vendor reference symbol. In this example, the lookup code is
V\REFITEM1. - Verify the REFSTAT_CODE for the active label in the Symbol form for VENDOR, on the Reference Status tab. In this example, the valid code is
CURRENT. - Use ACME as the rowKey. The vendor code is stored in the OBJECTCODE column of the generic reference table.
- In FsValidationField or the Validation form, review the entries for V\REFERENCE without a VALIDATION_SUBCODE.
- Check the V\REFITEM Lookup Set to find the lookup code for the Vendor reference symbol. In this example, the lookup code is
- Example 10
-
Set the "Child Project Status" to "Approved" for project NPD0123.001 in an Extension table for tracking sub-project activities.
ObjPropertySet("FINAL", 1, "FIELD6.MATRIX.V\DMPROJECT3", "", "", "NPD0123.001", "FIELD2");Edge
- Review the Extension Table Definition form. In this example, the extension table has View ID
3, and child project status is column (Field) 6. The project codes for child projects are in column (Field) 2. - Identify the enum configuration for FIELD6. Review the enum list, query, or lookup to determine the correct code for approved. In this example, the enum code is FINAL.
- Review the Extension Table Definition form. In this example, the extension table has View ID