logo

NJP

Using #ServiceNow Flow Designer to close parent when child tasks are complete

Import · Sep 13, 2022 · video

hey everyone welcome to another go with the flow this is a series where i teach you something about flow designer and do as few video edits as possible today i was browsing the servicenow community and i found a thread where a user wanted to close a change whenever a change task is closed and they're asking about ways to write the code there's two things that i worry about with this approach the first is that a change can have multiple change tasks so we want to be very careful about the trigger to close the parent from the child record the second thing that worries me is that this is not a problem that requires code if you understand flow designer you can do this very quickly and easily with absolutely zero code so in this video we are going to close the parent task when all the child tasks are closed i'm going to be using a table i've created on my instance called thing and thing is a type of task and it has and it has thing tasks which are child tasks so whenever all the child tasks of a thing close we want the thing to close so here we are in flow designer the first thing we are going to need is a trigger the trigger is going to be when one of these sub tasks is updated to closed so our we're going to do a record updated as the trigger it's going to be on the table of thing task thing tasks again are the child tasks to my thing we're also going to add conditions because there's very specific updates we're looking for we're looking for when one of these closes so i'm going to add a filter and i'm going to say the state is not is sorry changes to and close complete or closed incomplete or closed skipped we also want to make sure this runs on every single update we want to make this evaluation so for every update and there's our trigger always be a good steward of your flow there's other people that are going to look at this they might not be as talented as you so leave a plain english interpretation of this when thing tasks are closed okay the first thing we have to figure out is when this subtask closes are there any subtasks left of the same parent that are still open there's nothing about the parent that can tell us this information we have to go query for our peer sub tasks so we are going to take an action of look up records now there are two flow actions look up record and look up records so keep an eye out and make sure you're picking the right one otherwise you can be like me and record for 10 minutes not knowing that you picked the wrong action where are we going to look up the records we're going to look up the records of the thing task table again these are the child's records of my thing and we are looking for very specific conditions on these records because they must not be close complete closed skipped or closed incomplete so state is not one of those complete closed incomplete and closed skipped it's not enough that i picked the subtasks that are not any of the closed flavors they must also be for the same parent so let's put a condition for parent is how do we figure out the parent we go to our trigger record look up the properties of that record in our data panel find parent and drag that onto our always be a good steward put a plain english interpretation of this counting number of non-closed subtasks now that we know if there is open subtasks on the parent or not we can make a decision and decide what to do after that so to mark our decision we're going to have a flow logic of if and if how are we gonna figure this out well we're gonna take the count of the records from node one so we have this lookup records and we are going to see the count and we're looking for a count of zero meaning there are no records on the parent that are open or not closed you got to watch your double negatives okay so now that we have that if statement if it's true we're going to take an action we're going to update the work notes and the state of the parent thing so let's take an action let's update record which record are we going to update that should be super easy we're going to go to our thing task record parent so that's updating the parent of the record that triggered this workflow and we're going to add a couple fields most importantly state and we're going to set it to close complete and we're also going to add something in there because we're going to update the work notes and i've got some template text here subtask which subtask is it we're going to grab our trigger records and we're going to grab its number i'm going to drop that into our text so subtask this number is the last remaining task to close therefore i'm automatically closing what the triggering records parent number so i'm going to dot walk through my data list here parent and number and just for giggles i'm going to put an else in here okay so if it doesn't do this if then it's going to do something else so it's going to again we're going to update a record so action update record it's going to be the same record so we're going to get the parent of the triggering record and we're going to up to update the work notes and subtask blank has closed but a count of other subtasks remain so the sub task is go back to our trigger record grab its number and we're going to replace this count here with the count of my lookup so that would be node one my lookup records and i'm gonna drop the count in there so we've got some nice rich information in our work notes okay let's give it a test okay i have this record called thing001002 it has a bunch of thing tasks on it all of them are closed in real life this workflow would happen on the change of one of these things tasks to close but right now we want to simulate something with everything closed on it so we're going to take a look at uh 1007 as our test case so we go back to our flow designer we test and we're going to grab this thing task and we're going to run the test and we're going to view the execution details and it looks promising it looked up the records it completed it evaluated the first if statement to true and it completed the update record action in there and it did not fire the else because it ran the if let's go to our thing record let's go to our thing record we see it's closed complete and we see a work note where we see the subtask number is the last remaining task to close and so we're automatically closing this parent record so i made the assumption that you want all your subtasks to close i might not be right maybe you do want it so that if a specific subtask closes the parent task closes as well that's still totally possible and you still don't need to code it you can be in your flow designer and simply change the conditions for your trigger and there you have it folks a totally codeless way to change the state of the parent based off of the nature of the children hope there's something useful in there and we'll see you on the next one if you're a servicenow expert looking for better opportunities but maybe your resume or linkedin profile isn't doing you justice reach out to me via linkedin or the email pictured here as i offer both career coaching and recruitment services and if you're a servicenow customer or partner you heard that right robert fedoric now does servicenow recruiting with a 1500 subscriber youtube channel and mailing list and thousands of linkedin followers let's make sure your open positions can first go with the prodigious pool of servicenow resources reach out via the emailed picture here

View original source

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