How can we handle the following approach using the ERPNext 15 workflow file?

How can we handle the following approach using the ERPNext workflow file?

We have a form filled by the user where they select whether an advance is required (Yes/No). After submission, the request goes to the Administrator and COO for approval. At this stage, two fields — amount_to_be_paid and remarks — should be editable by the Administrator and COO.

  • If the request is rejected, the remarks field should be mandatory.
  • If the request is approved, the amount_to_be_paid field should be mandatory, and remarks should be optional.

These two fields should only be editable by the Administrator and COO during the approval process. After they are filled in, the values must be saved to the database and also be visible to the original requester in their view.

Hi

The workflow states are required to be written with eval JS code by customizing subject doctype as following;

The dependencies of Mandatory and Optional can be achieved by applying same JS code in Depends on and Mandatory Depends on with respective workflows states.