Requires a Business rule to Clear the "Assigned to" field when the Assignment Group changes ?

sriharshabalsu
Kilo Contributor

In an incident form whenever the "Assignment group" changes the "Assign to" field should be cleared, if that assignee doesn't belongs to that group. I required a business rule for aabove requirement.

5 REPLIES 5

vab_13
ServiceNow Employee
ServiceNow Employee

find_real_file.png



find_real_file.png



Script:



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




  // Add your code here


  var objUserMember = new GlideRecord('sys_user_grmember');


  objUserMember.addQuery('user',current.assigned_to);


  objUserMember.addQuery('group',current.assignment_group);


  objUserMember.query();


  gs.log("VAB:DEBUG: "+objUserMember.getRowCount().toString().length);


  if(!objUserMember.next())


  current.assigned_to = '';


  current.update();




})(current, previous);







Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!



Vab


Hi Vab Singhal,


Thanks for the update. But it is not working for me..


instance: https://demonightlyhelsinki.service-now.com/nav_to.do


login id = admin


password = admin



Business Rule:


https://demonightlyhelsinki.service-now.com/nav_to.do?uri=sys_script.do?sys_id=4f2c129013a73200ed373...



Test user account: "abel.tuter"


https://demonightlyhelsinki.service-now.com/nav_to.do?uri=sys_user.do?sys_id=62826bf03710200044e0bfc...



This user "abel.tuter" has got two groups: "Network" and "Database"


Incident assigned to "Network" => "abel.tuter"


Change Assignment Group from "Network" to" Database" and Save =>Assigned to will not clear off


Change Assignment Group from "Database" to "Cab Approval" and save => Assigned To will clear off.





Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!


Vab


vab_13
ServiceNow Employee
ServiceNow Employee

Did this resolve your issue?



Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!


Vab