How to refer back a CR workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2025 07:48 PM
As per requirement i have created one new button "Refer back" and this button will be visible for all the apporvals record of Change request, so now approver will have 3 buttons in approval form such as "Approve", "reject" and "refer back",.
So now if approver clicks on the button "refer back" then workflow should be rolled back and it should be moved to assess state back, how is it possible, and this "refer back" button is visible for all the appovals for all the change type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2025 11:11 PM
Hello @VIKAS MISHRA
I believe you already have Ui Action named as "Refer Back" created on Approval [sysapproval_approver] table which will have condition as current.state == 'requested' then your script for UI Action will be as below:
(function executeAction(current, gForm, gUser, gSNC) {
var changeRequest = current.document_id.getRefRecord();
if (changeRequest && changeRequest.getTableName() == 'change_request') {
changeRequest.state = 11; // Assess state if you have custom state adjust as per your configuration.
changeRequest.update();
// Optionally update workflow context or restart workflow
var wf = new Workflow();
wf.restartWorkflow(changeRequest);
}
current.state = 'refer_back'; // Custom state if needed if you are showing in choice list.
current.update();
action.setRedirectURL(changeRequest);
})(current, gForm, gUser, gSNC);
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2025 12:32 AM - edited ‎05-05-2025 12:33 AM
HI,
I added this script in my refer back UI action, but its not at all making any change.
Specially i want my workflow to be restarted from assess stage not draft and the approval stage should be changes to "refer back" and comment also shiuld be mandtory while clicking on refer back button.,
Generally we have the roll back activity in workflow which connects to the proviious activity where stage is "access" when we click on reject button in apporoval, but here we have a new button "refer back"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2025 04:02 AM
Hello @VIKAS MISHRA
Your Ui Action script must be as below:
(function executeAction(current, gForm, gUser, gSNC) {
// To make comment mandatory
if (!current.comments) {
gs.addErrorMessage("Please provide a comment before referring back.");
action.setAbortAction(true);
return;
}
var changeRequest = current.document_id.getRefRecord();
if (changeRequest && changeRequest.getTableName() == 'change_request') {
changeRequest.state = 11; // Assess
changeRequest.update();
// Set a flag to trigger rollback in workflow
changeRequest.u_refer_back = true; // Create this new field if not present
changeRequest.update();
}
current.state = 'refer_back'; // Custom state, ensure it's defined in sys_choice
current.update();
action.setRedirectURL(changeRequest);
})(current, gForm, gUser, gSNC);
In your Change Request workflow:
- Add a Rollback activity from the Approval stage to the Assess stage.
- Add a Decision activity before the Approval stage:
- Condition: current.u_refer_back == true
- If true → route to Assess
- If false → continue as normal
This way, when the "Refer Back" button is clicked:
- The u_refer_back flag is set.
- The workflow hits the decision node and rolls back to Assess.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.