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

Hi Harsha,

i was engaged with project stories ,i will provide updates on this .

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

Why are you using business rule ? 

You should do this validation only inside ui action either client side or server side script. 

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

find_real_file.png

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 ?