Making Worknotes mandatory when changing assignment group in any state of catalog task .

Chaithu3
Tera Contributor

VERY IMPORTANT..  URGENT..!!

Whenever an assignment group is changed in any state(i.e. open , work in progress , blocked , pending , onhold , close complete , close incomplete , close skipped) worknotes should be mandatory . User should provide reason for assignment group change.

Please create a new new business rule on Catalog Task table(sc_task ) which runs on update call .
Below are the filter condition for BR
State is Anything and Assignment group changes
worknotes should be mandatory.

 

ANYONE PLEASE HELP ME WITH A CODE IN BUSINESS RULE

@Ankur Bawiskar  @Pradeep Sharma 

1 ACCEPTED SOLUTION

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

So let me explain to you what my first script does. The code is triggered, once you set the NEW value into the assignment group. It checks the following:

IF the new value of 'Assignment Group' is different than the old value (the one was there when the form is loaded) AND the 'State' field is 'Open/Work in Progress/Pending' then it makes the 'Work notes' field mandatory. Please NOTE: if you changed the assignment group, set the status to 'Open/Work in Progress/Pending' and the work note became mandatory, then IF you do not submit the for but try to change the state to not of these there above (let's say 'Closed complete'), then, OF COURSE, the work notes will REMAIN to be mandatory because the 'Assignment group' is still other then it was when the form is loaded.

You cannot expect the 'work_notes' field to be set back to the optional if you change the state to another one BUT the Assignment Group field contains the new value. You have to save the ticket and afterward change it to the new state. The client script is constantly checking the assignment group field. This is its nature, otherwise, you can't control the change of assignment group field. I hope it now finally makes sense.

 

View solution in original post

28 REPLIES 28

Thank you for the information @Pavlo Rudenko 

when we change the assignment group after that we are not changing it back to old assignment group.. when the assignment group is changed then we are simply changing the state of the particular task..

as i need that it should work like a ui policy 

when we selecting open,wip and.. after changing the assignment group then worknotes should be mandatory and after changing the assignment group to other and changing the state to closed complete,incompete the worknotes should not be mandatory.

 

 

Thanks 

 

So do you mean that the 'Assignment group' field must NOT be checked for defining the mandatory work notes? If yes, then you should create 'onChange' client script on 'State' field:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

if((newValue  == 1) || (newValue  == 2) || (newValue  == 5)) //set your required values
g_form.setMandatory('work_notes', true);
else g_form.setMandatory('work_notes', false);
	
   //Type appropriate comment here, and begin script below
   
}

Hi @Pavlo Rudenko 

Im so sorry for explaining it badly to convey it.

i need to check both assignment group and state.

when i change assignment group to another group..

it wil be in open----

then i change to wip-----

then ill keep it to on-hold --------

then ill keep it to close complete---

this all im doing with one time change of assignment group and im not saving the form simply changing the state and checking how the worknotes is becoming mandatory..

ill open one task and change the assignment group then the state change to open for new assignment group then again i dont change group ill change only state to on-hold and again im changing only state to closed complete or in complete..

 

just check in this way and please tell me how it works

 

it is not working as expected...

 

 

Thanks for the pateince @Pavlo Rudenko 

 

P-Rudenko-SN
ServiceNow Employee
ServiceNow Employee

So let me explain to you what my first script does. The code is triggered, once you set the NEW value into the assignment group. It checks the following:

IF the new value of 'Assignment Group' is different than the old value (the one was there when the form is loaded) AND the 'State' field is 'Open/Work in Progress/Pending' then it makes the 'Work notes' field mandatory. Please NOTE: if you changed the assignment group, set the status to 'Open/Work in Progress/Pending' and the work note became mandatory, then IF you do not submit the for but try to change the state to not of these there above (let's say 'Closed complete'), then, OF COURSE, the work notes will REMAIN to be mandatory because the 'Assignment group' is still other then it was when the form is loaded.

You cannot expect the 'work_notes' field to be set back to the optional if you change the state to another one BUT the Assignment Group field contains the new value. You have to save the ticket and afterward change it to the new state. The client script is constantly checking the assignment group field. This is its nature, otherwise, you can't control the change of assignment group field. I hope it now finally makes sense.