AddContextAttrib

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

Purpose

Assigns an object to one or more context attributes.

Syntax


Dim variable As Long = AddContextAttrib(Symbol, Object, AttribCode, Value1 [, Value2, Value3,...])

Arguments

Part Description
Symbol Type of object, such as formula. Use empty quotation marks to indicate the current symbol for the workflow or the new object for the copy method.
Object Object code for which to add context attributes. Use empty quotation marks to indicate the current object for the workflow or the new object for the copy method.
AttribCode The type of attribute to which context is assigned. Use these codes:
  • C_BRAND - brand
  • C_PRODTYPE - product type
  • SELLOC - selling location
  • MFGLOC - manufacturing location
  • C_ENDUSE - end use
  • C_ENDUSER - end user
Value1 The first attribute to which the object is assigned.
Value2 Optional. Additional attributes to which the object is assigned.

Description

Use AddContextAttrib to assign context information to an object. Returns the number of attributes to which the object is assigned or zero for an error.

Examples

This example assigns selling locations CA, MA, and TN to formula PIZZASAUCE\003. These locations must already exist in the database.


Dim lSell As Long = AddContextAttrib("FORMULA", "PIZZASAUCE\003", 
"SELLOC","CA", "MA","TN")

This example uses HasContextAttrib to check if the object of the workflow or new object is assigned to the FOOD end use. If not, it is assigned the context.


Dim lUse As Long = HasContextAttrib("","","C_ENDUSE","FOOD")
   if (lUse = 0) then
     Dim lAdduse As Long = AddContextAttrib("","", "C_ENDUSE","FOOD")
     MessageList("This formula is for enduse: Food.")
end if

This example determines if the object of the workflow or new object is assigned to one of the pizza sets. If it is, the object is assigned to the end-use context attribute of the pizza.


Dim lSet As Long = HasSetCodes("","","MEAT","SAUCE","DOUGH")
if (lSet > 0) then
    AddContextAttrib("","","C_ENDUSE","PIZZA")
end if

Copy Method example

You can construct a copy method to add context attributes to the new object. In this example, the selling location is added using the second Auto Code segment. The brand is added using the third Auto Code segment.


Dim rc As Long
rc = AddContextAttrib("","","SELLOC",CopyMethod.Context.GetSegData(2))
rc = AddContextAttrib("","","C_BRAND",CopyMethod.Context.GetSegData(3))