logo

NJP

ServiceNow introduction to remote table | ServiceNow remote table to retrieve table external source

Import · Mar 28, 2022 · video

[Music] hi all and welcome back so in today's tutorial we'll be creating an application from the scratch to the end so today we'll be creating a weather application we can say okay and we'll be using a concept in service now which is called remote tables which a lot of a lot of people are not aware about so why we have to use the remote table so we came across a lot of situation in the development activities okay throughout our career where we want to do some evaluation on certain data which is stored on external system you can call it like y integration but you don't have to you don't want to store the data on your system on servicenow system there may be a couple of reasons for that but i think personally the most common two reasons will be first the data is huge or redundant so we don't want to store all the data on the system or the second one is like you the data which we are pulling is a confidential data so we don't want to store on the system so what we'll be doing today we will try to build an application okay which will uh which will pull the data on the on we can say current basis uh of the weather reports okay for the provided latitude and locations and then we will try to generate some reports around the same okay so let's get started so let's first start creating the application so for that i will go to studio on studio will you create application and create application i will get application name i will give it weather app i will give the description this is the app for voting of weather anything over here i will not give the image for now okay i will go to create and now we'll be creating a draw so rose i will give what kind of road i will i want to give let's give it like um let's give it itl for now idl root and we'll continue we want to go with the classic mode i don't know why i'm not getting the this problem i always face that will zoom out for a second then i will zoom out tables so it's asking me to create a table search existing database so we want to create a new table so what we'll be doing over here uh create a table from scratch again i have to zoom out i didn't get this continue button okay so for this reason i have to get out again and again so what basically we are to do we will be using this api so this ep is a weather api from rapid apa and what exactly it does we have to provide we have to provide it latitude and longitude and based on that it will give the current or temperature and you can say wind speed we see temperature over here so i will be taking wind speed temperature what else i want i think that that will be the only thing for now okay and let's take cloud wind direction wind speed some some some of the attributes i will take so let me take those attributes only so first of all what is the first thing the first thing is wind speed so we'll give speed okay i will just change it out to my attribute from that api wind speed then what we want to do is no it will not fall over here so i will not take that i will take temperature and this will be wind speed will be a float do we have float float float float float load point number okay and add field i will make the other field what select temperature and make it as damp it should we also float and one more field what else we want when direction right we so we will take wind action south so we will give wind direction and i will give it a name and i will make it a string field anything else i will make it hundred anything else what we what we feel we should use it out time stamp this is the most important thing oh we will give add field time i'll give it a name as timestamp utc and for now i will keep it as string because i don't want to get into conversion and all that things okay so i think this should be enough i'll scroll down oh my god this help for me now plus what this table label table name so we will give it like weather information or we will give it as weather and it will have this extension make extensible auto number just make it auto number oh we don't need this also okay we don't need this let's continue if you want to store the data we'll be using this out done with the tables start create i think i made a mistake i i don't need this thing out so i will click on this weather report as i mentioned we'll be using a remote table so i will not use this table out so let's go over here and i will search for i think i have to refresh it out weather app okay and now what we'll be doing will not use the that table whichever we have created we will create a remote table so we'll go for remote table so what remote table does i will explain you first so if i go to so docs remote we can also call it as crypto table so what exactly you can create remote table to describe the schema for the data that you want to retry from an external source the table definition is in the now platform but its rows or external record live in the memory so basically what in simple word what it means to say it will act like a simple table but it will not store the data the data will not be there you can only display the data from the external source on the table okay let's not go into there so let's click on new and i will give it a name as weather whether and i have to again do this it will be whether this and then we want to create a menu yes create a new menu with weather name and now i have to give again the column names so i will take the reference of this table only wind speed temperature okay i want this oh only right i will take column name also okay let's create it out now so the first one will be temperature temperature and the type is the name spam so i will i will give it type as float the second one is what timestamp will give it a name as string for now we'll be changing it in the future tutorials then the third one is wind action sorry for the previous table and wasting your time so we will give it as a float wind action was string right yeah when direction was string so we'll give it a string and the fourth was wind speed right that will be float perfect so we have created table weather and you can see there is a checkbox called remotable which will signify that it's a remote table we are creating a model called weather and we have created this attributes temperature timestamp wind direction wind speed and we'll keep on adding attributes to this in the future so i will save it out and now one thing to be observed over here so you can see there are no out of the box field created okay like create a created by update update buy and delete or activate it because this is a remote table nothing will get stored on the servicenow instance okay everything will be from the external system so that's the reason now we have created that remote table now the next step is like if we have this api we have to integrate this api right so let's try to integrate this api then so we will go over here we'll create a rest message we will create a new rest message and yo we will go to the code snippet and the code snippet i will uh okay it's already javascript java query so this is the url right for the epa so let's take this ui so we will give the apa description this is api now we will provide the endpoint so let's provide the end point in endpoint we have hardcoded values so this values i got for pune okay for now let's go with the hard code value then we will make it dynamic okay or if we want we can make it and i'm taking three hourly report okay and what else is required for this side in kodi and we have to define this headers so it's get and this head does okay perfect so we will go over here and we'll define the hair dash for the same so i will take the header it's the first header is host one and it has a value of the api which api we are using so basically the rapid api is the repository of free apis okay you can get you can use those out i missed this first thing again we have to go [Music] pretty quick studio i will go over here and we will give the key for the same okay and we will save it out now we will create a res the resource got created for the same so we'll go to the resource it will and we will do test let's hope it will work it gave an error 401 invalid api key to do to do okay fine i think we have to set the headers over here also i messed that out so we'll open this out i will minimize this let's see if header got okay we don't have headers over here right so the first data again we have to give ah this is pretty easy to implement and i'm doing it for the first time with this particular implements i've done integration in the past but with this particular api for the first i thought i was giving a try i should shoot a video also so we have given headers and let's give it a start test and we got 200 perfect this is what we were expecting with a lot of messy response so now we got a response right now how to add this response to our remote table right that's the next challenge so first of all i want to understand this jason because it's pretty messy so what i will do i will just go to json land i'll press this out and i will do valid adjacent so now you can see there is a d array of data okay area of data and inside that we have this object which we'll be using and this object yeah its own ending over here okay so there is a weather object also inside but we will not using that now we got the response now we have to go now how to fetch the data to the remote first of all let me show you the remote table so if we go to weather this is what happened over here so this is the weather model okay which we are having okay now inside this weather we have to we will again go to the remote table and we have to define the definition for the same so we have defined the table first now we will define the definition for the same so we'll go over here click new this is where we are defining the logic to extract the data okay for the weather table so we will give the name as it has a lot of boilerplate code but i will not pay attention to that with the definition the definition and here we will give it a name as weather okay and now here is the script right it has already given up a lot of boilerplate code okay encoded queries and all that things this is how you can pull the data and using this particular statement add rows you can push the object to the table so what we'll be doing over here now we have the scripted rest api right by that script address the api oh i missed that [Music] so descriptive rest api so we will be extracting the code for the same so i will do private previous script usage [Music] come on it's getting so slow why i want you okay i click on this and generated the code so we will be taking this code only and now we will go to the definition i will leave this till here i will paste our code so let's remove this support part only i don't think it's of any use to me for now so basically what is doing try scripted test api dtd we don't have to define anything like over here so we will remove this also execute response body okay response body response status and now we can give f http status equal to equal to 200 because we want to execute the further logic if it's successful only then what we'll be doing you must be knowing right there was oh how exactly it was first of all let's see how exactly it's coming so i will take this up and i will go to the explore we'll paste this out and see what response we are getting what happened we have to go to weather app and refill out now granted yes i didn't give print for this so i will give oh dot those rings wow it's giving object i know this jason fire um let's see if i do dot data let me see this object okay how exactly is everything state only right sorry response body my bad my bad my bad my bad so we are getting this kind of data so if i do response body dot data let's play with this data for now oh i i did the string if i write that's the reason let's remove this string reply let's keep it as object only if i do dot type off i'm just checking whether it's an object or string fit string right so we have to do it json.pass so i will give response body sun i'll give it a name and i will give json dot path and and run this we want this now it's when you are not sure right keep how the data is coming you have to do these things out so in this dot data and now it should give the array so it gave the array okay and now we will iterate through this array okay so i will take this code only as a code [Music] if response code is equal to a so here now we will give the logic okay so for that what i have to do while for a variable i equal to zero i less than what's wrong with my keyboard for variable equal to 0 i less than our response body json dot data dot length and i plus plus so we'll be trading over that data length and how we'll be trading over there is we'll be creating an object so i will give create variable why it's coming every time i am passing variable row object equal to i will give it an empty object and now we will be setting the attributes for that object so you can simply do this like this i just want to know the attributes so let's go to the weather table configure table and now we'll take this attributes and put it over so there are four attributes temperature and it will be i dot we have to see what was there for temperature or i can check from here also am right in the similar way we will be adding four other attributes also so we have four attributes right comma and we will do it the same for four attributes so one two three four i'm creating a lot of mess today i guess three four so the first attribute is temperature what is the second attribute its timestamp the third attribute is wind action and the fourth attribute is wind speed now again we will move to set this attributes right so the first one temperature second we want timestamp the timestamp will be taking time stamp utc the third one is wind direction what is there for wind direction bro is the wind direction with direction with action wind action or let's take this wind action full for that because it's a string field right and the fourth one is wind speed as the wind speed when speed okay now we have done with the integration over here now what we have to do once this object is created okay we have to add it to the row okay add it to the table so that's where this particular line come into existence so this is follow this is row object and the flow object we can give this but we have to stringify or we can directly add it like this let's start this way only and here i will give what object and ctrl a shift tab and i will save this out i think this is all we have to do okay now what exactly we are doing we are calling the rest api pulling the data passing it out in the format okay in the object format for the weather table which we have created we are just pushing it out as a row so if i go and see the less layout for the same right all right sorry my bad if i go and do show list for the same now you can see all the data has been pulled out for this particular integration perfect right i'm very happy with this progress so now this data is not present on the system okay this this data is present on the external system we are just showing it out on the list layout okay you don't believe me see if i do click i and if i open this record see there's nothing i told you right there's nothing everything is on the list now let's create a report for the same okay so i will go right click and what i want to do i want to create a bar chart for the same hope this is clear to you you guys so we have done with the integration creation of application and integration so just give create a report so ideally i think mark chart will be the best thing look so i don't want to do with group by temperature let's do it with timestamp okay so that will come to know okay how exactly it's looking right and stacked by we will do not count also now let's keep it account okay and if i do next so yo configure i'm making something some mistakes i want to group 5 times 10 you can create a report over here okay i think this is already been maximum temperature okay next so now you can see on which particular what was the temperature right so this is how we have created what exactly we've done for today's tutorial we have created an application then we have created a remote table then we defined an integration and using that integration we pulled the data to the remote table and then we created report for the same so this is all for today's tutorial hope you like this tutorial i try i was i was explaining on my own i thought okay let's do it together okay if you have any suggestion any comments i know i missed one part because where we where i don't want to create a custom table but apart from that if you think something needs to be improved please let me know okay till then stay safe stay happy and have a nice day thank you you

View original source

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