Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Is that possible to change planned start date and planned end date in the change request

nameisnani
Mega Sage

Hi ,

 

We have a requirement that in the change request Planned start date and Planned end date field to be not greyed during the entire life cycle for users under assignment group -

 

Is that possible , please help me on this below request 

 

SunilKumarPadh_0-1666881979934.png

 

@Saurav11 

 

16 REPLIES 16

HI @kamlesh kjmar 

 

In the change form we have department field , in the department field we have three department , based on the department user select the Assignement Group is changing , 

 

we have 4 Departments - associated with groups ,

 

but in my requirement , For XYZ group , planned start and end date should be editable ,

 

Note - The XYZ Group is not Associated with the departments.

SunilKumarPadh_0-1667201716253.png

image is business rule written in the change request table ,

 

SunilKumarPadh_1-1667201806944.pngSunilKumarPadh_2-1667201841922.png

 

 

@nameisnani ,

 

For this write a Display Business rule with condition and script as shown below :

kamleshkjmar_0-1667202282174.png

 

 

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var assignedTo = current.getDisplayValue("assignment_group");
	g_scratchpad.isGroupMember = gs.getUser().isMemberOf(assignedTo); //Checks if the logged in user is member of the assignment group and sends the result to client side

})(current, previous);

 

 

2. Write a client script as shown below:

kamleshkjmar_1-1667202577480.png

 

Script:

 

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var chgState = g_form.getValue("state"); // Assuming scheduled and implement is -1 and -1
    if (chgState == '-2' || chgState == '-1') {
        if (!g_scratchpad.isGroupMember) {
            g_form.setDisabled("start_date", true);
            g_form.setDisabled("end_date", true);
        }
    }
}

 

 

NOTE : Don't forget to deactivate the UI Policy written before to make both field readonly.

 

I Hope this helps.

 

Please mark this helpful if this helps and Accept the solution if this solves your issue.

 

Regards,

Kamlesh