- 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-05-2021 02:25 PM
You can write client side script in UI Action to validate if those two fields are empty make it as mandatory.
and popup alert to inform user to fill those two fields .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 02:39 PM
yes, i tried below scenarios.
UI action : Request Approval
g_form.setValue("state", "-3");
var start=g_from.getValue("start_date");
var end=g_form.getValue("end_date");
if(start!=""&&end!=""){
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_cab_approval');
}else{
g_form.setMandatory('start_date');
}
}
if (typeof window == 'undefined')
updateAndRedirect();
function updateAndRedirect() {
current.update();
action.setRedirectURL(current);
}
Business Rule: on Approval Table
var gr=new GlideRecord('change_request');
gr.addQuery('sys_id',current.sysapproval);
gr.addEncodedQuery('active=true^type=normal^start_dateISEMPTY^end_dateISEMPTY');
gr.query();
if(gr.next()){
gs.addInfoMessage(gs.getMessage("Please fill Planned Start Date/ End Date"));
current.setAbortAction(true);
}
above two things not working, state value moving forward and approval record was approved.
can you provide any inputs on this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 02:43 PM
You have to return false in client side script if field is empty and update record only when two field are not empty

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 09:27 AM
Any update on this thread?
If your query has solved, kindly mark the answer as correct and close this thread.