RemoveContextAttrib

You can use the RemoveContextAttrib function to remove an Optiva object from one, several, or all context attributes.

When to use

You can use this function to remove all context attribute assignments of a specific type from an object.

Syntax

long RemoveContextAttrib(string objSymbol, string objKey, string AttribName, params string[] @params)

Parameters

Parameter Type Required Description
objSymbol string Optional

The symbol of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
objKey string Optional

The key of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
@params string[] Yes The variable-length parameter array containing one or more attribute values to remove.
Note: You can use empty quotation marks "" to remove ALL attributes of the specified type.
AttribName string Yes The type of context attribute to remove. Possible values:
  • C_BRAND - brand
  • C_PRODTYPE - product type
  • SELLOC - selling location
  • MFGLOC - manufacturing location
  • C_ENDUSE - end use
  • C_ENDUSER - end user

Return Value

The application returns a value equal to zero (0) if the context attribute or attributes are removed successfully.

Impact

  • The application immediately persists changes to the database.
  • The object is no longer associated with the removed context attributes.

Prerequisites

  • The context attribute type must be configured in the system.
  • The specified attribute values must currently be assigned to the object for removal.

Examples

Example 1
Remove Specific Brand Attributes from Formula.
long lRemovebrand = RemoveContextAttrib("FORMULA", "PIZZASAUCE\\003", "C_BRAND", "ACME", "GENERIC");
Description
This example removes ACME and GENERIC as brands for the PIZZASAUCE\003 formula.
Example 2
Remove All Selling Location Attributes from Current Object.
long lRemovelocation = RemoveContextAttrib("", "", "SELLOC", "");
Description
This example removes all selling location attributes from the workflow or new object.
Example 3
Conditionally Remove Product Type Attribute Based on Set Code.
long lSet = HasSetCodes("", "", "FROZEN");
if (lSet == 1)
{
    long lRemoveproduct = RemoveContextAttrib("", "", "C_PRODTYPE", "FRESH");
}
Description
This example checks if the workflows object belongs to the FROZEN set code. If so, the FRESH product type attribute is removed from the object.