ObjectSaveAs

You can use this function for Optiva Workflows and Copy Methods.

Purpose

The function ObjectSaveAs is used to create a copy of an object to a new key code.

Syntax


long ObjectSaveAs(string objSymbol, string objKey, ref string newKey) 

Return Value

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

Arguments

Part Description
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 current object key of the data.
Note: Use empty quotation marks to indicate the current object of the workflow.
newKey

The newKey resembles the key of the newly created object.

The key is passed by reference, so the function can assign a new value (the key to the new object) directly to the variable provided by the caller enabling the caller to receive the newly generated key after the object copy is created, without needing to return it from the function separately.

Description

ObjectSaveAs copies an existing object keycode to a new object keycode. The new object keycode does not exist in the database before you run the workflow or copy method.

Example

In this example, formula PIZZASAUCE\003.002 and item OLIVE_OIL_BULK do not exist in the Optiva database before you run the workflow or copy method.


Dim lSave As Long = ObjectSaveAs("FORMULA","SAUCE\003","SAUCE\003.002")
Dim lSaveItem As Long = ObjectSaveAs("ITEM","OLIVE_OIL","OLIVE_OIL_ BULK")

Example 1:

string newKey = "SAUCE\003.002";
	long ObjectSaved = ObjectSaveAs("FORMULA", "SAUCE\003", ref newKey);

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:

string newKey = "OLIVE_OIL_BULK";
	long ObjectSaved = ObjectSaveAs("ITEM","OLIVE_OIL", ref newKey);

This example determines to duplicate the item "OLIVE_OI

L" into a new item "OLIVE_OIL_BULK",and stores the success or failure result in the variable ObjectSaved.

Example 3:

string CodeNumber = GenerateCodeNumber("EXP FORMULA");
	long rc = ObjectSaveAs("", "", ref CodeNumber);

This example determines to duplicate the object upon which the workflow is launched into a new object based on the CodeNumber generated from EXP FORMULA create rule.