CreateObjectUsingCreateRule

You can use this function for Optiva workflows.

Purpose

This function creates a new object using Create Rule.

Syntax

long CreateObjectUsingCreateRule(string objSymbol, string createRule, string copyMethod, Hashtable codeSegments, ref string newKey)

Return Value

If the code is successful, a value zero (0) is displayed and negative (-ve) if failed.

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.
CreateRule The created rule that is associated with the object must be provided.
CopyMethod The copy method associated with the create rule value must be provided.
codeSegments The hashtable containing the code segment names with the create rule value.
Note: Pass an empty hashtable if there are no code segments tagged to the create Rule.
newKey The function call holds the new object name after an empty string is passed, 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

CreateObjectUsingCreateRule creates a new object with the help of Create Rule internally by calling the Create Data using Create Rule API.

Example

In this example, a new Trade Item object is created using Create Rule.

Dim newKey As String = ""
Dim sItemDescription As String = ""
Dim htCodeSegments As Hashtable = new Hashtable()
htCodeSegments.Add("Company Prefix","000002")
htCodeSegments.Add("GTIN Type","GTIN-12")
htCodeSegments.Add("GTIN Template","FOOD")
Dim saveStatus as long = 0
saveStatus = CreateObjectUsingCreateRule("TRADEITEM","NEW TRADE ITEM","NEW TRADE ITEM",htCodeSegments,newKey)

Create a Trade Item using create rule - NEW_TRADE_ITEM, copy method - NEW_TRADE_COPY.

string newKey = "";
	Hashtable htCodeSegments = new Hashtable();

	htCodeSegments.Add("Company Prefix", "000002");
	htCodeSegments.Add("GTIN Type", "GTIN-12");
	htCodeSegments.Add("GTIN Template", "FOOD");

	long createStatus = CreateObjectUsingCreateRule("TRADEITEM", "NEW TRADE ITEM", "NEW TRADE COPY", htCodeSegments, ref newKey);
	

Create an Item using create rule - NEW_ITEM, copy method - NEW_ITEM_COPY.

string newKey = "";
	Hashtable htCodeSegments = new Hashtable();
	long createStatus = CreateObjectUsingCreateRule("ITEM", "NEW_ITEM", "NEW_ITEM_COPY", htCodeSegments, ref newKey);