logo

NJP

#11 Create Action To Get The Daily Data, Transform Map, Automate The Import With Schedule Import

Import · Aug 03, 2020 · video

hi everyone so in this video we are going to create our second floor designer action which is actually going to get the today's data we are also going to create our own beer source and later I'll be writing to our staging table then we will create also a chance for map and transfer the data from our from our staging table 12 target label which is going to be our cryptic table then we will automate the entire process by creating a scheduling port and it may be running on daily basis okay so it's good to ServiceNow studio and then click on did point E string and details the for designer action that we have already created so the good thing here we can just create a copy of that action all you need to do is to click on this three dots here and then click on copy action so they're paid of this text and then put get today's coin details ok I'm going to click on copy ok so I have my clap in here so I don't need this one I'm gonna just close that one so in this area designer action I don't need to do any modification on this level so getting the coin details such as IDs flag symbol name and UID website URL so if we're gonna keep these two step as it is so what we are going to do is just make some modification on this level rest a bit coin history so I'm going to change the title to get the base calling details okay here I'm going to have seven days instead of five years so let's click on sale and then I would like to show you one thing which is the decent response that we get if you send to this specific endpoint that we have here okay so in this online tool I have their JSON response for a Bitcoin and you can see here how many elements that we have in our history area we have a hundred and sixty nine elements and the good news is we have the same number for all coins okay the same number same length for the history array and if you want to get today's data I don't need actually create a loop in my script in order to run into this all this result and result and then find today's deal I would just need to go to the last one that I have here this is actually the latest data okay if I take the time that I have here this is in UNIX times I'm gonna just put in this kind of online converter and just to show you this is going to actually give you today's date I mean the day I'm recording this video so you can see here I have the number and then I have also the date okay so let's go now to our four designer action in the past step we don't actually need all this arrays we are not going to use it so I'm going to delete all of them okay and for the cold is exactly the same I don't need most of the lines that I have you so let me delete everything that I don't need okay so this is quite simple in the beginning we are checking if you have a successful response with the status quo valuable okay then we are passing a response body and storing it into our response body valuable then we create an object and we have pricing times time we're going to access the value by the disinfects mystery and I have something here we type the line so what I should put here it's going to be a 168 because I have 160 9mm it goes from zero to 168 okay so I'm gonna put an output object okay so I'm gonna have but okay dad coin okay because I have already coin object so I'm gonna have coin which will be equal to point or me shape great so I have created my point object so let's create that sorry my coin output variable it's also an object so otherwise I'm gonna pick on create valuable this is an object so look for object select object click on the plus button here so I'm gonna have the first child which is price and the second one which is time stop click on save and make sure that we have the same thing you are doing the same thing here so we don't need all these arrays now click on edit outputs and delete all these always so let's create a new one and call coin it's going to be an object and child here price and the second chart time stop okay click on save click on exit no and then just driving Bob do you will do that here that I have here that we have here okay right click again on save and publish it right so now what we are going to do we are going to create our data source so click on this three dots here click on course new pet and then I'm going to just copy this part of the cool this is what we are going to use in our data source so I don't need this one anymore so I'm going to close that one okay I forgot to do something is I'm going to show you we have to test it right so we have to see if it is working so let's go and then do a quick test so last year put one run test let's see the result so as you can see here I have the details and I've also the coin price and time stamp great so let's go and put this right here and I'm going to just you need everything that I have already and we will be writing our script step by step okay let me just zoom a bit okay let's put first our the code snippet that we have copied okay this is my cost you and I'm gonna remove everything that I don't need so this part and also in this bar okay so what we want is we want to run a script which is actually going to call the floor designer action eight time because we have eight coins and we have our input here which is empty and each time is going to whenever is going to call the four designer action we should have a certain values certain value here and Kyle is going to be either 1 or 13 or 59 or 23 something like this okay so for that the first thing what I'm going to do I have I'm going I'm going to have all the variables here okay I have it already here I mean all the points so I'm gonna just copy and then put it here okay I have all my coins okay well Bitcoin equals 1 what - equal to 13 and and so on then I'm going to put all this coin into an array so I can access them from an array okay so let's copy Gary and put it here okay so if you want to access Bitcoin well you should do is coins 0 0 good Bitcoin if you want to access - you even do coins 0 1 okay so I have the kind of visual representation here of the array so 0 0.01 - you to create and and so on so next is [Music] so you not to call 8 times you are going to create a loop which will be running a time okay so I'm gonna have four loop Bar a equal to zero a smaller than 8 and a-plus-plus crap just open it and then I'm going to close it here what I'm going to have I'm going to have coins brackets okay reckon brackets twice and then the first value is going to be 0 all the time the second one I'm going to have a variable here which is going to be a ok the previous writing our script in for the data source and we should put here to string you pay otherwise it will frame okay so I'm going to put the same to you so like this so will not fail so so in this way we're going to have eight loops and each time you're going to have the value of of the coin so it's gonna have one 1328 it's going to call the the floor designer action with input then get the output okay in here now you're going to create an object which is actually going to we're gonna collect the data okay I put it in the object so that's going to be my map object that's what I have here so let's take everything that I have you I'm going to put that into my coat so what I do here I create a map object we have you under school name-calling object that names is how we can access them the name of the coin would be coin object and then the timestamp I'm gonna just put not timestamp but babe okay and then we have the price as well from the coin object okay then we do import underscored set and school table that insert map is it is actually going to put all the data into our staging table okay so I guess we are done with the scripting part for our data source that's all we need to do and yes it is okay now I'm going to just copy everything let's go to studio click on create application file that little source look for data source click on create and let's give it a name here just put today's details data source I'm gonna have the same name here today's details staging table let's stop here custom the pipe here is going to be custom build basket sorry and that's placed I will put here ok then click on take care so you can arrange it like this so we have our coins we have our area we have our loop we have our object here which is having on getting all the deal and then we are inserting and that great so it's all good I'm going to just save it and click on load order cards let me just check if I did two days coin details it is published or not it should be yes so click on no audio cards this is when it is actually going to create the staging table okay so you can see here today is coin details data so staging table is created and we have processed 8 that's what we want impaired we don't want 169 or cause we want only those eight reports for each coin we have one record okay so now we are going to create our transform app so click on preview transfer map and let's give it a title I'm going to put two days these transform map so this is going to be our source tables already selected okay the target table is going to be crippled table okay 300 and click on something and then click on all map matching fields so we should have to feel so I have you date and then price and I'm going to click on mapping Isis to get the name my cone so I'm gonna have here name put it here and here I'm gonna have point great okay so one thing we still need to do here is for the big field so this do you have the next time in our let's say you know stays in table let's see that so if I click here then you scroll down go to show list this is the last import set so we have eight rows click on this and you can see here the date we have the unix time okay so so we have to write the script so we don't need to rewrite it we have already [Music] in the audio transformer so what we need to do is just go to our what is that historical data transform app and then click on script here so take everything okay copy then go back to your transform app here click on a date use source script check that box just delete everything here and then paste it okay so everything is good here let's save this one great so before running our transform app we should go into our table because the historical dia have also today's data okay for this date I have it so I should go to my table and delete today's data and then I'm going to transfer map to see if I'm going to get today's data so let's go to click on show list so I have it here just click on show matching select all and then delete okay so as you can see here I don't have today's data now let's go to 12 transform map okay today is calling video transform map and click on transform so if we have our input set here our map is already selected click on transform it was so quick it is done so let's go to our table and see if you have to go today any of your cards okay you can see here for today I should have eight records let's see that perfect I have all the records that I want so the entire process okay so click on create application Fri and then go to schedule and it's going to be a schedule data import in going to ration click on that so let's put I'm I'm going to put today's details schedule input okay the data source is the today's coins detailed data source okay I'm gonna put here for example 8 and then click on something great so we have done with the schedule data import as well so I would say we have done with the entire part let's say for the integration ok we have finished with this entire workflow so the next thing what we are going to do we are going to work with performance analytics and then start to create our indicator in case or breakdown breakdown source and all this kind of thing and so thank you for watching hope you like it and bye

View original source

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