For information on setting up a conditionally valid attribute, see the Conditional Attributes documentation in the System Setup / STEP Super User Guide
It is possible to make use of the Conditionally Invalid Values binding in a JavaScript business action. This will resolve to a (possibly empty) set of values, and this set will contain all values which has value conditions that for the current node evaluates to false.
Note: Note that this Binding is unrestricted in the sense that it is always available not just from workflows or imports, etc.
Here is a JavaScript example for clearing conditionally invalid values.
Required bindings:
//acquire an iterator - easiest way to deal with Sets
var iter = invalid.iterator();
//iterate over conditionally invalid values
while (iter.hasNext()){//get the value
var val = iter.next();
//test if there is a value and if it is local
var clean = val.isLocal() && val.getSimpleValue();
//do some chatting to the log
var msg
if (clean)
msg = "Cleaning up";
else
msg = "Ignoring";
msg += " conditionally invalid ";
if (val.isLocal())
msg += "local value";
else
msg += "non-local value";
msg+= val.getAttribute().getID() + " [" + val.getSimpleValue() + "]";
logger.info( msg );
//in case of local value - delete it
if (clean) val.setSimpleValue("");//empty string handled as null and deletes local values}
It is possible to make use of the workflow state bindings for conditions and actions that, on the import, can resolve and be used for general evaluation and handling of the product being imported.
Here is an example business condition that be applied on import of a maintenance Smartsheet, exported from the Web UI Task List.
Required bindings:
state:"Workflow state"-binding
node:"Current Object"-binding
logger:"Logger"-binding
//up front test if the import carries expectation of specific workflow state
if (!state) {logger.info("No import state provided");//could have instead return some rejection to say no import if a state is not supplied
return true;
}
var instance, task, msg;
//acquire the workflow instance for the node and workflow
instance = node.getWorkflowInstance(state.getWorkflow());
if (!instance) {//simply reject since workflow has been terminated or never started
msg = "Rejected : Workflow " + state.getWorkflow().getTitle() + " not started for " + node.getTitle();
logger.info(msg);
return msg
}
//now look for actual task for node in supplied state
task = instance.getTask(state);
if (!task){//no task also causes rejection
msg = "Someone might have changed data " + node.getTitle() + " has no task for state " + state.getID() + " in worflow " + state.getWorkflow().getTitle();
logger.info(msg);
return msg;
}
logger.info('Accepted: we have a task and will now continue with import');return true;
2017, Stibo Systems