logo

NJP

ServiceNow – Display Variables on Target Records

Import · Jul 19, 2022 · video

hi everyone in this video we are going to learn how to display the variables from your record producers onto the target records that they create so you may have already seen this in incident forms so if you create an incident for example from a record producer there is a default incident variables editor that you can display it's not there by default and it will capture all unmapped variables as well as map variables on the form so if you come to your form design here you'll find that there is an incident variable editor formatter already available it's not displayed by default but you can just bring it over from your list of formatters and that will display all the variables both mapped and unmapped that you've captured in a record producer but did you know you can actually add or create your own variable for any table at all to do the same thing so what you need to do is go to your list of formatters look at the one for incident variable editor see what macro it's using and then just copy that over to your new formatter so at the moment i've got a new table here just a test table just with two fields if you look at the the list of records here there's nothing here at the moment but it just contains two fields that's it in addition to that i've also created a record producer to capture both field one and field two here which are both mapped to those respective fields but also a third field here which is unmapped as you can see it's not mapped to any field in the target table if we look at the record producer it looks a little bit like this so let me go ahead and add some values here and submit it so we've got the record created if i come back to the list refresh we've got the record generated if i open it we only have the first two values captured so if we come and have a look at the form design we'll see here there's no corresponding formatter here uh for this table so all we need to do is go and create one really easy to do i'll just come over here to my formatters open it let's have a look at the one for the incident table already the incident variable editor that we're going to use as the basis notice here that there's a reference here to a formatted this is actually a ui macro so if you actually go to your ui macros here you'll find it's a some jelly code that actually generates uh or displays those variables so this is it here so this is actually what we need to reference when we create our own formatter we don't need to do anything else we don't need to change this code this has already been pre-configured for us to display all the variables that have come from the record producer so if we come back to our formatters this is the one that we need to to copy over so all we need to do is come back create a new formatter call it whatever we like so we'll give it a name and then just copy and paste that ui macro that we referenced earlier specify the table name where we want to make that formatter available so in this case it's going to be my test table and that's it save it and now if we come back to our form design refresh the page we can see the test formatter is here drag and drop it put it wherever you like save it come back to our form refresh it and now you can see it's captured all the variables there from the record producer and now what we could do what we maybe should do is actually use a catalog ui policy to hide the first two fields because there's no point really in displaying them again when we've already got that information captured and displayed in the target fields here so that's it that's how you go ahead and create your own formatter and add it to a custom table to display variables that are unmapped as well as mapped from a record producer

View original source

https://www.youtube.com/watch?v=2TDBxkFOu0c