Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Checking for transition in Condition and Validation, Script

3 REPLIES 3
Reply
Message 1 of 4
sten
514 Views, 3 Replies

Checking for transition in Condition and Validation, Script

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.

3 REPLIES 3
Message 2 of 4
Andrew.Shaw
in reply to: sten

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,



Andrew Shaw
Premium Support Specialist PLM/PDM
Global Services
Autodesk, Inc.

Message 3 of 4
sten
in reply to: Andrew.Shaw

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

 

 

 

Message 4 of 4
Andrew.Shaw
in reply to: sten

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,



Andrew Shaw
Premium Support Specialist PLM/PDM
Global Services
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report