how to add foreign key table column in table

pratap1
Giga Contributor

Hi there,


how i can add table column as foreign key in table?

Thanks

Best reards,

Pratap Ranawat

1 ACCEPTED SOLUTION

Uncle Rob
Kilo Patron

ADDING A REFERENCE FIELD TO A TABLE



find_real_file.png


View solution in original post

6 REPLIES 6

Chuck Tomasi
Tera Patron

Hi Pratap,



What is the underlying requirement here? Normally ServiceNow admins don't really care about primary keys, foreign keys, and other database layer details. It is handled as part of building your data models (tables, reference fields, etc.)



Which is why I'm curious as to what the goal, objective, requirement, etc. is.



Thanks


Uncle Rob
Kilo Patron

Last time I used the term "foreign key" was on MagicTSD / Remedy.   I'm going to assume you want a field to be a reference to another table.


For that, define the field with a type of Reference.   If you're doing that via the dictionary, you'll be forced to tell it what table you want to reference.


If you're coming from the Magic / Remedy space, forget about the concept of "virtual fields".   The reference field itself will visualize the display value from the table its referring to (rather than just a sys_id).   If you need more fields from the refering table you can traverse the reference via form customization to pull fields from referred table.


Uncle Rob
Kilo Patron

ADDING A REFERENCE FIELD TO A TABLE



find_real_file.png


Uncle Rob
Kilo Patron

Traversing a Reference to Add Field from Referenced Table to Form



find_real_file.png
After you've clicked the expander button between the two field lists, everything refreshes....



find_real_file.png