Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

field to show up and be editable if assignment group is x or is changed to x

Ponnada
Tera Contributor

how to make a field editable and visible in ritm and task when assignment group = x in task or is changed to x.

I have a field called issue details it should be visible and editable only when assignment group = x in taskor is changed to x in task.

I created a catalog client script for this as given below:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var RequestItemId = g_form.getUniqueValue();
var taskGR = new GlideRecord('task');
taskGR.addQuery('request_item',equestItemId);
taskGR.query();

if(taskGR.next()){
var assignmentGroup = taskGR.assignment_group.getDisplayValue();
//var previousAssignmentGroup = g_form.getOriginalValue('assignment_group');

//Check if assignment group is x
if(assignmentGroup ==='x'){

//Make the 'issue details' field editable in catalog form
g_form.setReadOnly('issue_details',false);

}else{
g_form.setDisplay('issue_details',false);
g_form.setReadOnly('issue_details',true);
}
}

but when i am using it it is only satisfying one condition for me which is assignment group = x not if it is changed to x. Could anyone help me with this. I need a solution urgently.

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

@Ponnada 

 

You can create a UI policy like below

Add your catalog item and assignment group in condition

ManmohanK_3-1688056210443.png

 

Add script like below

ManmohanK_2-1688056139688.png

 

 

View solution in original post

3 REPLIES 3

Manmohan K
Tera Sage

Hi @Ponnada 

 

You cannot use Glide Record in client script. Also, You don't need a client script for the above requirement.

You can do this using a UI policy and avoid writing so much code

Manmohan K
Tera Sage

@Ponnada 

 

You can create a UI policy like below

Add your catalog item and assignment group in condition

ManmohanK_3-1688056210443.png

 

Add script like below

ManmohanK_2-1688056139688.png

 

 

Hi Manmohan,

 

Thank you so much. I changed the table to sc_task and did every thing else as in your reply.I also used a catalog ui policy for ritm. They are working.