- 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 10:03 AM
Hi Harsha,
i was engaged with project stories ,i will provide updates on this .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 11:51 AM
Hi Harsha,
Still issue reproducing , i used below BR on Approval table . but still we can approve approval records and Change request changed state to Scheduled.
How to stop this
Business Rule : table : Approval |after|update
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.sysapproval);
gr.addEncodedQuery('active=true^type=normal^start_dateISNOTEMPTY^end_dateISNOTEMPTY');
gr.query();
if (gr.next()) {
gs.log('Dates updated');
} else {
gs.addInfoMessage(gs.getMessage("Please fill Planned Start Date/ End Date"));
current.setAbortAction(true);
}
Change UI Action : Request Approval
function moveToAssess() {
var start = g_from.getValue("start_date");
var end = g_form.getValue("end_date");
if (start != "" && end != "") {
g_form.setValue("state", "-4");
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
}
if (start == "" && end == "") {
alert("Fill Dates");
return false;
}
}
if (typeof window == 'undefined')
updateAndRedirect();
function updateAndRedirect() {
current.update();
action.setRedirectURL(current);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 01:00 PM
Why are you using business rule ?
You should do this validation only inside ui action either client side or server side script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 01:04 PM
Hi Harsha,
i tried below conditions in UI action, not single condition working fine.
please suggest me solution for this.
Change UI Action : Request Approval
if (g_form.mandatoryCheck()) {
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_cab_approval');
}
OR
Change UI Action : Request Approval
function moveToAssess() {
var start = g_from.getValue("start_date");
var end = g_form.getValue("end_date");
if (start != "" && end != "") {
g_form.setValue("state", "-4");
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
}
if (start == "" && end == "") {
alert("Fill Dates");
return false;
}
}
if (typeof window == 'undefined')
updateAndRedirect();
function updateAndRedirect() {
current.update();
action.setRedirectURL(current);
}
when we try to approve approval record then approval records don't approve &
don't change state value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 01:10 PM
let me read your requirement again,
First case: you want your UI Action should make field mandatory when your planned start/end date is empty, so this should be done via UI Action.
Seconds Case: You want when ever user approve the change approval request, then it should abort the update because your change request planned start and planned end is empty , this should be done via business rule.
Correct me if i am wrong.
If i understood it correctly then in which case its failing ?