Autodesk,
I know it is possible to consolidate multiple validation scripts into one by checking the workflowState.
Is it possible to do something but instead of validating based on the State, then validate based to the chosen transition.
If so, can this be done in condition scripts to?
If possible, please post a small code snippet as example.
Hello Sten,
A workflow transition can be assigned a precondition and/or a validation script.
You can also run a script when the transition is performed.
All of this should cover your needs.
As for code snippets, I suggest you refer to the Developer's Scripting Guide in the online help.
Best regards,
yes, but that was not really my question.
I know how to make the condition scripts, what I don't like is that I end up with so many condition scripts with only a few lines of code.
I belive that maintainability would be improved if I could consolidate all condition scripts for a single workflow into a single script. I do that sometimes by looking at item.descriptor.workflowState. The problem is that just looking at the workflowState is not sufficient if there is more than one transition out of the state, and I was hoping that somehow I could test on the transition to see where I am in the workflow.
An alternate solution to consolidating multiple condition scripts into one would be to allow arguments to the condition scripts: Idea
Hello Sten,
You could use the following code to know the "from" and "to" states:
var fromState = item.workflowActions[0].transition.fromState.stateID;
var toState = item.workflowActions[0].transition.toState.stateID;
You could implement this in an action script that would be executed when the transition is performed.
Then, using control statements such as "If-Else" or "switch()", direct the code to the required resolution. You can find more info about the "switch" function here.
Obviously, if your workflow is very complex and has many states, you would end up with a lengthy script.
Hope this helps.
Best regards,