How to make Planned start date/End Date as mandatory in Change request

Sironi
Kilo Sage

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.

find_real_file.png

 

OR

find_real_file.png

1 ACCEPTED SOLUTION

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);
}

View solution in original post

22 REPLIES 22

Harsh Vardhan
Giga Patron

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 .

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.

You have to return false in client side script if field is empty and update record only when two field are not empty

Any update on this thread?

If your query has solved, kindly mark the answer as correct and close this thread.