logo

NJP

Document ID field - Did You Know

Import · May 24, 2023 · video

foreign our situation this time is that we're building a simple personal to-do app that needs a field that can put you any record in any table as you probably already know a reference field can point to any record in a specified table like the assign to field on any task references records from CIS user but it can't point to another task for example well did you know there's a field type that can reference any record in any table on the system it's called a document ID field let's take a look here's our to-do app to add a document ID field we'll go to the form menu and select configure form layout there are other ways to do this configure form design not being one of them for some reason anyway we're going down here where it says create new field we're going to add a new field called document and use the type document ID we'll click add place it on the Forum layout near the parent field and Save there let's have a look there's our document ID field and when we click it it prompts for a table and a document and as you can see the table drop down doesn't work we'll need to also create a table field because the document ID field is actually two Fields just like you see in the modal a table and a document let's click cancel and fix that back to configure form layout We'll add another field called document table and select the type table name add it to the form and Save there it is at the bottom of the screen on purpose to demonstrate something first we need to do one more thing we need to make the document field dependent on the table we'll right click on the document field label and choose configure dictionary in the dictionary entry click the related link Advanced View under the dependent field tab we'll click use dependent field and select the document table from the list one more update and let's retest our document field voila we can select any table and any record from that table and when we click OK look how it's displayed in the field we see the table and the record display value and if you've got a Keen Eye you've probably noticed that the table field at the bottom of the form has done nothing so far until we save at which point it takes the value we specified to avoid confusion let's remove the table field from the form it really doesn't impact the functionality of the document ID field at all and when we use the form menu to show the XML we could see the value of the document field as a sysid and the document table is the name of the table containing that record now let's say we're writing a script and we want to get access to that document the first two lines of the script simply get our to-do record line four creates a Glide record object based on the value of the document table field and the document field value is the record sysid to fetch in the next line the output validates we've got a record from the table another way to do it with fewer steps is to use the get ref record method which recognizes the table field dependency and fetches the document Glide record pretty neat so now you know how to reference and work with any record from any table using a document ID field that's all for this time and don't forget if you've got a tip about the platform an app or capability share it with the world and don't forget to use the hashtag servicenowdyrk to be part of the community I'll be back soon with another servicenow Dyk thanks for watching [Music]

View original source

https://www.youtube.com/watch?v=FZ_gvKUKFpk