How to connect two fields for different tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 06:00 AM - edited 05-12-2023 06:03 AM
Hey all,
Hoping for some help. I have a couple of fields that I need to depend on each other, but they will have to do this for different tables. I'm not quite sure how to accomplish this.
Example: In one table (Location ID), I have four fields, but one is Location ID and the other is Location Name. I need them to depend on each other, meaning, that if someone selects the location name, it automatically fills the Location ID (so another one can't be chosen instead) and if someone selects the Location Name field, the Location ID field automatically gets filled in.
With that being said, I'm going to have to perform this on other tables, such as Location, Hardware Asset, Service Asset, etc. On those tables, both the Location ID and Location Name are reference fields. So, I need it that when a user selects either the Location ID or Location Name, it fills in the other field.
What is the best way to do this? I was trying an autopopulate Client Script, but it never seemed to work, so I'm wondering if there is a better way to perform this action.
Thanks,
Mat
#developer #scripting #connectingfields #dependentfields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 06:11 AM
Hi @Mat Gdowski1 ,
Please use the thread mentioned in the link: https://www.servicenow.com/community/itsm-forum/linking-two-fields-on-different-tables/m-p/859763
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 07:33 AM
@Community Alums - I think I need more help. I did read the link you provided (thank you). However, they talk about two different ways to do this: 1) creating two business rules (BRs) and doing two updates via a script and 2) dot-walking the one field and one referenced field.
Apparently #1 is not suggested per the ServiceNow employee that commented on that thread. However, no one actually provided the info on how to do the dot-walking to get these two fields connected. Could you please provide that info for me? I'm a bit lost there. I already have the one field in the Location ID table setup (Location ID field) and the Location ID field in the Location table is referenced to the Location ID field. So, that isn't a problem. I just don't know how to setup the dot-walking to connect the referenced field back to the Location ID table.
Plus, it seems like they were talking about referencing one field to one field. (Owner to Owner in two separate tables) I'm trying to link one field to another field in two tables. Location ID to Location Name in one table (Location ID table) and Location ID to Location Name in the other table where these fields are referenced (Location table).
If just "linking" the two fields (Location ID to Location Name and vise versa) in the one table (Location ID) will provide that same linked relationship when they are "referenced" in another table, then I'm good with that. But I don't know how to do that either.
Below is the excerpt from that link you provided above regarding them talking about dot-walking that I'm trying to figure out.
HI Nikita,
Instead of creating new fields in 2 tables,can't you use the dot walking method on the other table.
1.Lets say create owner field on the scheduled entry table.
2Create a new field scheduled entry (refferenced to schedule table)on the Events List [u_maintainance_blackout_change] table.
3.using dot walking get the owner field to the layout.
Let me know if you need help in this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 07:36 AM
I need to link two fields (Location ID and Location Name) on the same table (Location ID) and then reference that same pair of linked fields to other tables (Location, Hardware, Service, etc.). I hope that explains it a bit better/clearer for my purposes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 05:45 AM
Any thoughts from anyone? I still have yet to be able to proceed. Thoughts on how to link the fields using dot-walking?
