- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 02:18 PM
Hi,
Some one plese help me on below issue.
How to make Planned StartDate / Planned EndDate fields Mandatory when we click on "Request Approval " Button
OR
when we try to approve Change request Operation must be Abort and give warning message like fill Planned StartDate/Enddate don't empty.
OR
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 02:03 PM
try now
var gr = new GlideRecord('change_request');
gr.get('sys_id', current.sysapproval);
gs.log('planned start '+ gr.start_date +' == '+ gr.end_date);
if(gr.start_date =='' && gr.end_date==''){
gs.addErrorMessage("Please fill Planned Start Date/ End Date");
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 01:44 PM
Create a Data Policy (exactly this is why they exist) that sets "Planned start date" and "Planned end date" to Mandatory when state is one of (Assess, Authorize, Scheduled, Implement, Review and Closed).
Then in the UI Action you would write:
g_form.setValue('state', g_scratchpad.stateModel.stateValueByName.assess);
if (g_form.mandatoryCheck()) {
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_cab_approval');
}
This will change the state to Assess, as a result, because of the Data Policy, the Planned date fields become mandatory.
Running g_form.mandatoryCheck() kicks off the built in mandatory checks, if not-filled mandatory fields are found, that will be reported as an Error Message on top of the form and the function returns false - the form submission function (gsftSubmit) will not be called.
If all mandatory fields (including the planned date ones) are filled, the function returns true and the form will be submitted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 12:42 PM
Hi Janos,
Thanks for your valuable replay,
Kindly check below image.
i tried Your solution, but not working.
but when i tried to Approve Approval records which were created in state of "access" those approval records i can approve it. it should not happen like this .
if Planned start/End fields empty system should not accept Approval records as approve and Change record state value shouldn't be changed.
Do we need to modify Change request - Normal OOB workflow ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 01:20 PM
I suppose you did not create the Data Policies. Without those the UI Action code I have posted, is useless. If the Data Policies would be in place, than the WF would still be waiting @ activity "Wait for condition" Change moves to Assess.