logo

NJP

ServiceNow – Tokyo – Bulk update and delete records

Import · Oct 14, 2022 · video

welcome everyone in this video we're going to take a look at a brand new feature in the Tokyo release of servicenow to bulk update and delete records all without needing to script if you need to perform a one-off update of a lot of Records what options do you have you could create a flow using the update record action to cycle through some records and do it that way or you could write a script there are many reasons why you wouldn't need to do this perhaps the import that you have executed is not quite right it was incorrect some of the values of the data that was imported were Incorrect and you need to correct them it may be that the data model that you are dealing with has updated and that field values need to be changed from one value to another value there may be demo data that you want to update there may be many reasons uh you need to do this so as I said there is now an easy way to do this in servicenow or without scripting so let's take a look we start off first of all by going to system data management and there are two new modules here delete jobs and update jobs so let's start with update jobs and before I go ahead and create an update job let's have a look at the records I'm going to update so I've got here a list of Records in particular these first two here I'm going to update let's just say that for some reason the assignment group and the category of the incidents here just need to be updated that was just imported incorrectly or whatever so let's do that so in my form here for one of those incidents it's just a regular instance so we're going to go ahead and update the category from inquiry help to hardware and we'll also take care of the assignment group as well and change that from software to hardware okay pay attention also to this reassignment count field okay at the moment it's zero because this is a new incident I've just created it and when I created the incident I set the initial value for assignment group to software okay so let's go ahead back to our update job and click on new the first thing we need to do is to select a table okay so let's select incident and then we can specify the conditions so in our case the short description contains I think it was just test update so we've got a preview button here just to confirm that the records that will be updated are the ones that we want to be updated so here that's correct two records we want to update two records here okay and then we just go ahead and specify what field values we want to change so in our case it's going to be the category on the one hand we'll change that to hardware and then we'll also take care of the assignment group as well and so that is also Hardware okay all right these final two check boxes here I'm going to leave as they are okay so there is the option here for having this update actually recorded as an update so in other words the the time stamp for the update will be updated and a record will also be made of who executed this update in this case it's going to be me because I'm going to execute this job and the second option here is that you have the ability to turn off your engines and business rules so when the update is executed do we want to have all the business rules flows workflows whatever uh being triggered as a result of this update yes or no but I'll just keep both of those activated for the time being so I'll click on continue and as I said you can actually schedule this for some point in the future run ad in Just click on the calendar select the date and time the system will take care of that but we're not going to be very patient we're just going to execute this right now so I will go ahead and click on execute now okay proceed it's just a warning to say yes we are going to update records let's do it okay so that's executed now before we go to the execution results let's have a look at our incident the form here we can see that the category has changed the hardware the assignment group has also changed and also the reassignment account has been updated here that's actually a result of a business rule and because we had that check box ticked to say yep execute those business rules this field was updated accordingly okay if we go to our list and let me just do a quick refresh here you can see that the first two incidents are actually the second two uh the second group here of two records has been updated to Hardware okay so that works let's go back to our execution results there that will actually take us back to that job that we created here okay and we do have the option of rolling back so for some reason the update that we performed just now in order to correct data has somehow been Incorrect and we need to correct our correction uh we can actually roll back so if I actually go to view rollback contacts first of all we get some details here of what was changed and updated as a result of that update that we just executed so if we roll back what records are going to be affected because it won't necessarily be just the incident record or the target record uh Records that we've updated there could also be other records related records that need to be updated as well okay so um so we've got a list here of rollback records including the two incident records here okay and let's take a look a closer look at our incident here just to see what's actually being recorded in the audit Trail so if I go to my contacts menu and go to history and go to list and insulin is a task table or task tables are classified as audited Tables by default in the platform which means every single change is recorded so we can see here that the first update after the initial creation of the record so the update number here is one we change those values here those three fields and they were performed or updated by myself through this job okay let's go back now and do a rollback let's see what happens uh yes we do want to roll back so just confirm that okay all right or close that we'll go back to our list we'll just do a refresh here so those two incidents those update records here have now been rolled back to inquiry help and software respectively if I actually go back to the incident record here and we'll take a look at our values here okay they are as we originally had them and if we come back to the history here what you will find is that the initial update that we made through that job is recorded but the rollback is not so just something to keep in mind um when you're doing updates if you do want to have those changes recorded here in the audit Trail or not okay because the rollback that we just executed is not recorded here all right let's go back to our incident let's do one more test let's come back to my update jobs and we'll create a new one so that one has been executed now we can't go and run it again we actually have to create a new job so again I will select the incident table and I will specify the same filter so where the short description contains um so update test or test update I can't remember let's find out preview two records yep that's right okay and let's just do the same update again so the first field was category we'll make that hardware and then we'll make the assignment group equal to Hardware as well and this time I'm going to deselect these two here okay and save that or just click on continue as with every any update that you perform you'll have to just keep in mind what effect that may have on other records such as slas and so forth that may be related to it okay and we'll just execute this now proceed so we should find that the result is kind of the same not quite let's have a look we'll go back to our list we can see that the category and assignment group have been updated accordingly so that's fine okay but if we actually go back to this record here and have a look at our history well actually before we do that have a look at their reassignment account that has not been updated okay so we kind of rolled back to software we updated again the reassignment count didn't update because we deselected the option to run business rules okay and if likewise if we go to our history here and take a look at the list we'll see here there's also no record of that second update that we've made because we deselected the option to make a or track those changes or to record the uh who and when the update was executed all right so that's uh as I said a really easy way in which you can update records and servicenow without needing to script okay so let's take a look now at how we can bulk delete records in service now without needing to script so if you wanted to do that now what options do you have yes you could script you could also create a flow and use the delete record action This Time Again cycling through some records to remove or you could even use table cleaner but table cleaner is more for getting rid of older data on a regular basis such as import set data removing log entries that are no longer required or getting rid of older flow contacts that are no longer needed but one of you wanted to execute a one-off deletion of records for example imported data that has just been performed incorrectly you've got the wrong data in it's not quite right you want to get rid of it and try again or you want to just clean up some demo data or test data that you may have in a non-production instance of servicenow well there's an easy way to do this now using these delete jobs again under the new system data management application so before we start let's take a look again at the incidence we're going to remove these two records here with the short description demo to delete one and two Okay so similar to update jobs for our delete jobs we just need to create a new job and again we can execute it straight away or we could schedule it to be executed sometime in the future okay so I'm going to go ahead and specify the incident table okay I will select incident and again my filter condition here my criteria will be where the short description contains test delete actually that's incorrect it should actually be demo to delete so let's just preview that two records great okay so similar to updating records we've also got this option here to run business rules or engines so whether we want business rules workflows flows Etc being triggered as a result of this deletion so let's click on continue and keep that box selected okay now some of you may be familiar with Cascade delete rules so which determine what happens if a record is deleted what happens to all the related records do we keep them do we just remove the reference to that record that's been deleted do we delete the record as well that related record as well or not there are some other options available so at the moment um in our record count here we don't have any records appearing if I click on preview Cascade down here we'll actually find out you know what records will be deleted okay so at the moment uh we've got uh two incidents and two slas okay so if I go to my record here my record to be deleted we can see down the bottom here we've got an SLA okay so I will also be deleted as well as a result of the Cascade delete rules okay depending on what configuration you set up they may not be deleted but in this case they're going to be all right so we'll just go ahead and execute that warning yes we are going to delete records proceed okay and that's done so if we come back to our list here and just refresh we should only have two records here now so those two records are gone and if I come back to this page here and refresh we should get an error to say that the record hasn't been found yep record not found there you go okay let's have a look at the execution results again in other words that job that we just created and executed okay so similar to when you update records you also have the possibility here after deleting records to roll back and to put those records back into their rightful place if you've made a mistake so uh we can have a look at the rollback context again um we'll give you a little bit more detail on what records were deleted and maybe some other related records that were deleted in that process uh if we come back oops let's go back to our delete jobs here this one and we will execute the rollback okay so let's do that roll back okay yes we want to roll back close again like with everything you do in the platform if you're doing like a mass update or a mass delete of Records just plan it out just make sure that you know what you're updating what you're deleting is actually what you want that you know any related records that may be affected updated or deleted in your plan okay so you don't have any little surprises okay so if we come back to our list and refresh we've got the two records back there and if I come back to this page where the record was not found because we can see in the URL that there's a reference to the sys ID to that record so if I do a refresh of this page the same sys ID is retained which means that record that we deleted it's just put back where it was before now changes are made to that sysid so any references uh to this uh will still work okay and we should also have the SLE here as well okay everyone so that's it that's a really nice new feature in Tokyo for Mass bulk updates and deletions of Records without needing to script so I hope you found this video helpful and we'll see you next time [Music]

View original source

https://www.youtube.com/watch?v=iZ-Hf3QqozA