Self-referencing table

carlganz
Kilo Contributor

We have a VIP field and a Manager field in the user table. I need to create another field called IsManagerVIP which contains the setting for the VIP field of the manager record associated with this user in the same table I'd do this with a self-join in SQL. (Whether the manager is a VIP will determine how certain logic will be executed throughout the system.)

How would I go about doing this?

Thanks

Carl

1 ACCEPTED SOLUTION

jamesjurden
Giga Guru

Maybe add a dot-walked field to the manager.vip field?


View solution in original post

3 REPLIES 3

jamesjurden
Giga Guru

Maybe add a dot-walked field to the manager.vip field?


Chuck Tomasi
Tera Patron

Hi Carl,



ServiceNow provides a feature called "dot-walking" to allow you to access fields from reference fields' values. You can display the manager's VIP field on the user's form. The caveat is that it will have the same label "VIP". As a workaround, I recommend making a new form section for the manager information you wish to display.



You can also reference the values easily via script - this is where the term dot-walking comes from. For example, if I have a business rule on an incident and I want to know if the caller's manager is a VIP, it might look something like this:



if (current.caller_id.manager.vip)


        // the caller's manager is a VIP



Reference: Dot-Walking - ServiceNow Wiki


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Carl,



The first option is to have it via Dot-walking as suggested by Chuck.


If that doesn't fit your req then you can write a client script to achieve this. Please refer OOTB client script "(BP) Set Location to User" which sets location field on incident when caller_id field is changed.


https://YOURINSTANCENAME.service-now.com/sys_script_client.do?sys_id=5e524025c0a80166004d1761e85e205...



Client Scripts - ServiceNow Wiki



Please let us know if you are blocked.