How do I automatically update the selection of a choice field when another choice field from another table changes?

dmixer
Mega Contributor

Okay... to break down my question.

I am working with two tables, sys_user and the cmdb.

Basically, every user record in the sys_user table is assigned equipment that is stored in the cmdb table.

When a user leaves the company, their status (choice field) in sys_user changes from "Active" to "Termed"

Upon this status being changed from "Active" to "Termed", I need to change another choice field (on the users CI record) in the cmdb from "Active" to "Recover", so our team knows we need to get their equipment.

Example: John Doe is an Active Employee with Active equipment (iPad tablet) assigned to him. 3 months later, John quits so his record in the sys_user table changes from Active to Termed (via scheduled import) now his equipment status needs to change from Active to Recover - so my team knows they need to recover Johns hardware.

Whats in bold is my problem and I am looking for a way to automate these status changes. I am looking for an "out of the box" method of doing this since I have very little knowledge of javascript.

Would anyone be kind enough to point me to the right direction?

1 ACCEPTED SOLUTION

Hi Daniel,



Make sure that the field column name and the values are set properly in the script.


View solution in original post

12 REPLIES 12

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Daniel,



You can create a after BR on "sys_user" table and run it only when the status changes to Termed to update the users CI Record.


sumukh
Kilo Expert

Hi Daniel,



You can create a business rule on sys_user table:


state.png



P.S. : Your condition should be according to your status change and status value should be what you have for recover choice list value.



Hope this helps.



Thanks.


dmixer
Mega Contributor

Thank you guys!



...I feel like I'm in the right place working within Business Rules, but im still having difficulty. I have inserted the code above but its still not changing the status in the cmdb_ci when I change an employees status.



I will keep chipping away at this, but if there is any additional hand holding available, would certainly appreciate...


Hi Daniel,



Thanks for the update. Make sure that the choice value is properly injected in the code.


You can go to the cmdb_ci table and then go to the field "status"..Now right click on field-?show choice list->Now make sure that the value is properly scripted in the code.


Please let me know if you are blocked.