RemoveSetCodes
You can use the RemoveSetCodes function to remove an Optiva object from one, several, or all set codes.
When to use
You can use this function to:
- Remove objects from specific categories.
- Implement workflows that change object classifications.
Syntax
long RemoveSetCodes(string objSymbol, string objKey, params string[] @params)
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.
|
| @params | string[] | Yes | The variable-length parameter array containing one or more set codes to remove.
Note: The function passes an empty string "" to remove all the set codes from the object.
|
Return Value
The application returns a value greater than zero (0) if the operation is successful.Impact
- The object is no longer associated with the removed set codes.
- The removal may affect object visibility in filtered views or reports
Prerequisites
- The set codes must be configured in the system.
- The specified set codes must currently be assigned to the object for removal.
Examples
- Example 1
-
Removes Single Set-Code .
RemoveSetCodes("FORMULA", "PIZZASAUCE\003", "SUB");
- Description
- Removes SUB set code for formula PIZZASAUCE\003.
- Example 2
-
Remove all set-codes.
RemoveSetCodes("FORMULA", "PIZZASAUCE\003", "");
- Description
- Removes all set codes for formula PIZZASAUCE\003.
- Example 3
-
Remove specific set-codes.
RemoveSetCodes("ITEM", "OLIVE_OIL", "ORGANIC", "PREMIUM", "EXPORT");
- Description
- Removes multiple set codes for Item OLIVE_OIL.
- Example 4
-
Check PROJECTCODE and remove object from all sets.
object oProgram = ObjProperty("PROJECTCODE"); if (oProgram == null || string.IsNullOrWhiteSpace(oProgram.ToString())) { try { // Call RemoveSetCodes with the same parameters as your original call. // Verify API docs: return value meaning and whether "" removes from all sets. long lRemoveSet = RemoveSetCodes("", "", ""); // Optionally check lRemoveSet for a success/failure code here } catch (Exception ex) { // Replace with your environment's logging/trace mechanism Console.WriteLine("Error removing object from sets: " + ex.Message); } }
- Description
- In this example, the script checks if the workflow object or newly-created object belongs to a program. If not,the script removes the object from all sets.