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

Looking further, the "Recover" choice value isnt actually in the cmdb_ci, its in another table that is extended from the cmdb_ci...




Is that relevant?


Daniel,



So I am assuming that only items in the extended table will be marked as recover? If yes, then just change the table (cmdb_ci) in above code to the extended table and it should work.



Thanks.


dmixer
Mega Contributor

I changed table in the code and it still doesnt work... uploading screenshot to hopefully help SnowBR.jpgidentify if something is wrong... thanks for the help guys...


Daniel,



Remove the filter conditions and put this in condition instead:



current.u_employment_status.changesTo('T');



Just make sure that fieldname (u_employment_status) is correct.



Let me know how it goes.


dmixer
Mega Contributor

sumukh, thanks for all the help!



I have done as you asked, still not working. The business rule is active, though I'm not entirely sure how to see if its firing...


SnowBR.jpg


I have the BR set to run after a insert or update. Concerning the table, I have tried it with both cmdb_ci and with u_communication_devices, still no joy.



"Employee Status" with a choice value of T resides on the sys_user table and "Status" with a choice value of "Recover" resides on a custom "u_communication_devices" table, though *configure dictionary* for the Status field shows the field belonging to the cmdb_ci table



I don't expect anyone to post years of worth of javascript education on here... I was really hope for an "out of the box", easy mode solution... is there no other way do this?