ObjectSaveAs
You can use the ObjectSaveAs function to create a copy of an existing object with a new key code. The function duplicates the existing object and its associated data to create a new object.
When to use
You can use this function to:
- Create variations or versions of existing objects through a script.
- Create new objects based on existing object templates.
Syntax
ong ObjectSaveAs(string objSymbol, string objKey, ref string newKey)
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.
|
| newKey | string (ref) | Yes | The key for the newly created object. The function can assign or modify this value to reflect the actual key of the created object.
Note: passed by reference.
|
Return Value
The application returns a value zero (0) if the operation is successful.
Impact
- Copies all associated detail records, such as ingredients, parameters, and references, to the new object.
- Makes the new object available to authorized users.
Prerequisites
- The source object must exist and be accessible.
- The new key must be unique (not already exist).
Examples
- Example 1
-
SaveAs version supported object.
string newKey = "SAUCE\003.002"; long ObjectSaved = ObjectSaveAs("FORMULA", "SAUCE\003", ref newKey);
- Description
-
This example determines to duplicate the formula "SAUCE\003" into a new formula "SAUCE\003.002", and stores the success or failure result in the variable
ObjectSaved.
- Example 2
-
SaveAs a version not supported object.
string newKey = "OLIVE_OIL_BULK"; long ObjectSaved = ObjectSaveAs("ITEM","OLIVE_OIL", ref newKey);
- Description
-
This example determines to duplicate the item "OLIVE_OIL" into a new item "OLIVE_OIL_BULK", and stores the success or failure result in the variable
ObjectSaved.
- Example 3
-
SaveAs a Formula using a Code number generated from create rule.
string CodeNumber = GenerateCodeNumber("EXP FORMULA"); long rc = ObjectSaveAs("", "", ref CodeNumber);
- Description
-
This example determines to duplicate the object upon which the workflow is launched into a new object based on the
CodeNumbergenerated from EXP FORMULA create rule.