logo

NJP

What is Dot Walking in ServiceNow | How to access referenced table field values

Import · Sep 12, 2020 · video

[Music] in order to subscribe to my channel please click here or click here please share comment and like my videos and channel hello guys welcome to sas with servicenow this session is about dot walking in service now a lot of times you must have got requirement when you have to access fields of table of reference field value which is actually not on the same table you're working on then dot walking comes into the picture dot walking allows direct access to the fields and field values on reference records in conditions filters and scripting let's say you need to update the assignee of an incident as per the location of caller however location of caller which is referencing to the user table is not on incident table and you cannot access it directly in that case you can access caller location by dot walking access data of referenced table fields this is incident table in which you can see table fields now in this table there is one field which is a color field and this field is a reference field that means that this color field is referencing to the user table and that is another table now this user table has its own fields so if you want to access if you have to access caller field and for example you have to access first name you have to access last name email of caller in that case you have to do dot walking condition you can use dot walking in condition as you can see i have selected location from caller so i have to select i have to select the value of caller's location but location is not on incident table so in that case what i will do i will select the related fields in that case i will select the caller i will do a dot not an exactly as part of the script but there is an option which i will show you later in my personal developer instance and then you select location and then you can select the value for that particular field of that particular referenced field you can also use dot walking in scripting and the syntax is like object dot related underscore object and then you put the field name that means referenced field name as an example you can see we can access caller id email of for example on any incident record so if you want to access email of caller id the user who is in the caller field in that case you can use this kind of syntax that means current which is basically the object it can be gr as well if you're doing the glide racket then it will be gr or any variable or any variable you are creating for grade racket or if it's a current record then you have to use current dot color underscore id now caller underscore id is the field of current racket that means the current record the table you're working on its caller id field because that's a reference field but we want to access email value that means email of caller caller user who is in that particular field so in that case you will do dot and then you will access the reference table that is this user table and the field we have is email and we can access with this syntax dot walking in client script now i will show you a practical example in my personal developer instance that how exactly you can use dot walking to access reference tables in client script so this is my personal developer instance what i will do in order to show you this example i will show an alert in that alert we will try to access data of for example caller fields let's let's use the same example so in that case if i go over here and i go to list of incident i will just open list of incident now here if i will show you quickly and i open this particular incident now before i start creating this client script the important part is even it's a client script even it's a business rule even it's a server side script any kind of script or when whatever you want to whatever you want to achieve without walking the important point for dot walking is that dot walking can only happen for reference field it cannot happen for any any uh i would say direct field which is on the form like string field it cannot happen the string is just a static data which is on that particular field the only dot walking can work the only way is that is that field has to be referenced field that means it should refer a different table so that you can access fields of that table so in that case if i'm over here you can see we have caller is a reference field assignment group is a reference field we have assigned two is a reference field configuration item service these are all reference field so in this case i have this caller now i only have access to caller name you can see it showing the society now whenever you you refer any field that that feed is a reference field the only value which can capture on the form is society but now i have to for example populate email of this user but email is not available on this feed on this basically form on incident table how can i do that i can do it with the help of dot walking so let me do one thing let me create a client script so i will show you that how you can achieve this with client script this is new client script form i will just mention over here just a name i will mention and that can be demo dot walking and i will make it on load now here's the script now how can i use it for script so let me show you first first we will capture the value of caller id how can i do that i will just do color equal to and here i can do g underscore form dot so you can use get reference and if i do this so the reference i can do caller underscore id that's the name of the field now the another important point as you know forget reference is you have to basically declare the callback function so i will mention over here uh i will just mention maybe just call back that's it and that's how you you write it so this is my callback function now what i can do i can just do function call back and here i can just do alert and i can put here color and i can do let me show you the email of caller is space i can just put plus and here i can do how can i access now the value basically will be accessed in caller this that value will be stored because i'm just referencing that field with the help of get reference but how will i access email i just need to do caller.email that's it and if i just do like this and if i click on save that's it your client script is created and if i go to i think we will not open a new form we will open existing one where caller field should be there it should not be empty so i will just maybe this one if i open this one yep you can see pop up over here that email of caller is elva.example.com and this is the email address of this caller that's how you can do dot walking that means i can access the data the field value in the different table the table basically who's which is referenced in the current table with via any field why any reference field so that's how you can access that data but this is how you can do dot walking in client script dot walking in business rules so as of now we saw that how we can do dot walking in client script but now i will show you how you can do dot walking in business rules now business rule basically you write server side script in that case you don't have to use this get reference you can directly access the racket maybe it's a current racket you can directly access it so let me show you that as well so if i go over here and i go to list of incidents let's say and i will go to business rules and if i come over here and i will just click on new now we will show a message rather than alert because alert is client but this time i will show you the message so if i just put the value so name of the business rule so i will put the name of the business rule again it's demo dot walking that's fine i will check this advanced and let's say we will do it for display because we just want to show it that's it so and i can just come over here how can i access it so i have to do i have to first capture that value how will i capture so maybe i will just do where caller email i will do equal to i will do current dot what is that field caller id you can see we have this caller id i can access it but now i have to access the email it's quite simple i will just do dot that's called dot walking and then i will do email which is the field name of this user table so in that case i will do semicolon i will come over here and then i will do gs dot add info message and here i will do the email address of caller is space and i will do plus and here i can just do that's it nothing else you can just do like this caller email and you have to put semicolon over here and you are done this is how you do dot walking it is saved and now i will go to i will just like try to open any existing racket so let's say this one yeah you can see that email address of caller is elvar and this is the one which we created by a client script we can disable it as well and this one is via business rule so this is how you can access fields values of reference data in client script and in business rules i hope you like this video please like share comment and do not forget to subscribe to my channel have a great day

View original source

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