Validate for custom workflow


Wondering where we can find the code for Workflow.
Trying to understand the validation when we create custom workflow.

We would like to create workflow that is company specific. (i.e. workflow for Purchase Order, only on from company A)
However, currently, creating multiple workflow on same doctype is not permitted.

Kindly advice on any workaround or where I can find the code for workflow.
Thank you.

There is no need of code for creating workflow. Go to Setup >> Workflow Add States and Transition Rules.

For more information go through following links -

@Sangram, I see. In that case, is there a way to create multiple workflow for same doctype, by making it company specific :

You Can create multiple workflow against same doctype but you can active only one from them.
As you see there is Check-box Is Active

@Sangram, hmmm, if we were to have different Purchase Order Workflow for different companies, we would need them all to be active. Selection of workflow to be based on company. Was looking to analyse the possibility of this based on reading the backend code on the doctype. However, we are unable to find the Workflow module/code at the server side.

Wondering if there is any other way to set/change the docstatus of a doctype.

Thank you.

It will be possible. you have to write script for that. when you changes company, activate workflow for that company with script.

@asneha1, you can manage both workflows at the same workflow! But remember, that you ever will have 2 begins and 2 ends!

The unique hack required here is on validate event, you set the value of workflow_state field to the begin that do you want!

I know that it is a bit of macgyverism, but solve the issue!