yellow tassel

Ever wanted to reference a record on a form from a table name that is unknown during the form load? It could be calculated later or chosen from a different field.

Or maybe you wanted to add a reference to different tables with no common parent?

Either way, in ServiceNow, it’s really simple and here are some steps to achieve that.

Step 1 – Add field of type Table name

Even though you can find some documentation about this field type, it’s not very extensive. And there is a good reason for that – the field is really simple. It’s a dropdown with table names and a filter.

Nice thing about this field type is that you can also set its value with g_form.setValue() – simply provide the internal table name. This can be useful when you want to make the table name dependant on some other field based on custom conditions.

Step 2 – Add field of type Document ID

Now we need another field of type Document ID. Personally, I’ve never really understood why they exist. They are like reference but do not allow dot-walking. Now I know. Thanks to them, we can add a reference to any record in the system. Think of it as a sign. It only shows the way.

When you add it, make sure to make it dependent on previously added table name field. They work together really well and we can easily display document ids belonging only to our table name.

Step 3 – Now…


There is no step 3 actually, it just works together. Now you know how to connect records from one table to any other table in the instance.

Leave a Reply

Your email address will not be published. Required fields are marked *