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

-O-
Kilo Patron
Kilo Patron

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.

Hi Janos,

Thanks for your valuable replay,

Kindly check below image.

 find_real_file.png

 

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 ?

find_real_file.png

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.