ObjPropertySet

You can use this function for Optiva Workflow, Copy Methods, and Equations.

Purpose

The function ObjPropertySet sets the value of a field in the database and includes an argument for the new value and a save mode.

Syntax


long ObjPropertySet(string value, long saveMode, string propertyName, string objSymbol, string objectKey, string rowKey, long keycol);

Return Value

If the code is successful a value greater than zero (0) is displayed.

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);

Arguments

Part Description
Value The new value that you want to set to the Optiva field. Value can be of datatypes - string, int, long, double, Date Time.
saveMode Use 1 or 0 as the placeholder. This exists only for backward compatibility to older versions and has no function.
PropertyName The propertyName represents the name of the field that needs to be retrieved. Follow the same steps described for ObjProperty to derive the propertyName of the attribute.
objSymbol The object type or current object type of the data.
Note: Use empty quotation marks to indicate the current symbol of the workflow.
objKey The object key or the current object key of the data.
Note: Use empty quotation marks to indicate the current object of the workflow.
RowKey The ObjPropertySet() is only used to set data in an existing row of the table and there is no case where we can set data to an entire column,unlike ObjProperty().
keycol The keycol parameter is required when a rowkey has been specified to return table data.

To determine the Correct ColumnKey -

  • The Column Key is the DB_FIELD_NAME in the Validation form/table of the column that has the rowkey value (The Field Name of the column must not be used). Optionally, the FIELD_NO of the reference column (usually DEP_FIELD_NO) divided by 100 can be used but using the DB_FIELD_NAME is less likely to change over time or have a copy/paste error from some other source of code. Any column can be used for rowkey and keycol as appropriate.
  • •You can also use "ITEMCODE", "PARAMCODE"(to update parameter values), directly as the ColumnKey argument.

Description

Use the ObjPropertySet function to set values of fields in the database. The arguments of this function are the same as for the ObjProperty function. The SaveMode argument is reserved for future use.

When you include Auto Code segments that prompt users to specify a value for the Copy Method, use GetSegData(n). The n represents the Auto Code segment number to use.

Note: You can use a workflow to override security and change a locked or read-only formula. Use discretion when overriding security.

Example

Example 1: Set the Header description for current object

bjPropertySet("new description set from scripting", 1L, "DESCRIPTION");

			Value - new description set from scripting
			SaveMode - 1
			PropertyName - DESCRIPTION (In-Detail explanation of PropertyName argument is provided in the examples section of ObjProperty)
			Symbol - "" (Current Symbol)
			Object - "" (Current Object)

Example 2: Set the Component type(drop-down) of an Item to 'Raw Material'

ObjPropertySet(8, 1L, "COMPONENTIND");
			Value - 8
			SaveMode - 1
			PropertyName - DESCRIPTION (In-Detail explanation of PropertyName argument is provided in the examples section of ObjProperty)
			Symbol - "" (Current Symbol)
			Object - "" (Current Object)
Note: 
Please find the component types as per ENUMCODES - (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");
			Value - 8
			SaveMode - 1
			PropertyName - DESCRIPTION (In-Detail explanation of PropertyName argument is provided in the examples section of ObjProperty)
			Symbol - "" (Current Symbol)
			Object - "" (Current Object)
Example 2.2: Set the Class of any object to Default
ObjPropertySet("Default", 1L, "CLASS", "", "");
			Value - Default (Class name)
			SaveMode - 1
			PropertyName - CLASS (In-Detail explanation of PropertyName argument is provided in the examples section of ObjProperty)
		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", 2);
			Value - 22
			SaveMode - 1
			PropertyName - VALUE.TPALL (In-Detail explanation of PropertyName argument is provided in the examples section of ObjProperty)
			Symbol - FORMULA
			Object - REPL\0001
			rowKey - SODIUM
			keycol - PARAM_CODE ("SODIUM" appears in the "PARAM_CODE" column of the table)

Example 4: ay eniSet the amount of an ingredient, ITEM01, in any formula

ObjPropertySet(2.43, 0, "QUANTITY.INGR.A", "", "", "ITEM01", "ITEMCODE");
			Deriving PropertyName : QUANTITY.INGR.A
			Format : FIELD_NAME.INGR.VALIDATION_RECFMT

Let's frame the propertyName by following the below process.

  • DTLCODE can be found in the object specific objectdtlinfo table. The DTLCODES related guide is also attached for reference.
  • • INGR is the detail code for Item lines tab in FORMULA.
  • • As per objectdtlinfo (For FORMULA), G.FORMINGRED is the VALID_CODE.
  • • In G.FORMINGRED table, we have a column called VALIDATION_RECFMT whose value is A mostly.
Value - 2.43
			SaveMode - 0
			PropertyName - QUANTITY.INGR.A 
			Symbol - "" ->Current symbol of the workflow
			Object - "" -> 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.

Note: To make a formula a master formula, you must add an MFG item.
//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", "", "");

Example 6: Enter Approval Code in any Formula

	ObjPropertySet(100, 0, "APPROVALCODE.STATUS");
			// Value to set - 100
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"

  • First, check the V\REFITEM lookup set to find the Lookup Code for reference symbol = VENDOR. In this example, it is V\REFITEM1.
  • • Next, verify the actual REFSTAT_CODE value for the label “Active” in the user interface by checking the Symbol form for VENDOR, and Reference Status tab. In this example, the valid code is “CURRENT”.
  • • rowKey is the vendor code for ACME. That code is stored in the OBJECTCODE column (keyCol) of the generic Reference table.
  • • In FsValidationfield or the Validation form, review entries for V\REFERENCE with no VALIDATION_SUBCODE
ObjPropertySet("CURRENT", 1, "REFSTAT_CODE.REF.V\REFITEM1", "", "", "ACME", "OBJECTCODE");

Example 10: Set the "Child Project Status" to "Approved" for project NPD0123.001 in an Extension table for tracking sub-project activities.

  • First, review the Extension table definition form. The Extension table’s View ID in this example is 3, and “Child Project Status” is column (Field) 6. The Project codes of Child projects is column (Field) 2.
  • • Next, identify the enum configuration for FIELD6, and check the enum list or query or lookup to determine the correct code for “Approved”. In this example, the enum code is FINAL.
ObjPropertySet("FINAL", 1, "FIELD6.MATRIX.V\DMPROJECT3", "", "", "NPD0123.001", "FIELD2");