Dynamically Set Reference Field Table

Ken83
Mega Guru

Hello Community,

        I am trying to find a way to dynamically set the table name of a reference field onChange. I have a table with a dropdown(Field A) that contains all tables in our instance. Because that can literally be any table that exists, I need the reference field(Field B) to also be able to reference any table that exists and it should be based on the table chosen in Field A. So in Field A, if choose the Request table(sc_request), Field B should be updated to reference sc_request which would then allow me to insert any record from that table. Any ideas on how to accomplish this? I've seen the dynamic and advanced reference qualifiers but I haven't had much success with that.  

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Ken,



I don't think this is possible, and it would present some challenges down the road when you go to report on the table. Typically when ServiceNow needs to be able to reference any table in ServiceNow they use a document ID field.



What's the requirement here? I haven't run into this type of need before.


Yeah i came to that conclusion after doing some homework on it. I've got it working in a different manner using a Business Rule. I've got this complicated table structure setup but essentially I need to be able to traverse about 4 to 5 different tables and draw relationships between all of them for the sake of Related Lists. One of the tables, it only has a reference field and a description field. It turns out when records are created on that table, it takes on the sys_id of the record that created it, if that makes sense. So I was able to just use a Business Rule to get the values I need and do what I need to do from there.


Doanna
Giga Contributor

You can create a Document ID field instead of the Reference field.

The dependent value of the Document ID field should be a field of type Table Name

You can set the Value of the Table Name as the table you want the Reference Field to reference.

You can hide the field Table name via client script or Ui Policy if required.