logo

NJP

3. Subflows (reusable workflows)

Import · May 21, 2021 · video

now that we've seen how an action works in servicenow the next thing i want to do is show you the concept of sub flows and flows so we're going to go ahead and create a sub flow that's going to use the action that we were just looking at as well as take some additional steps that might be worthwhile so we're going to call this particular subflow demo subflow capability and i'm just going to copy that just that subfloor name to the description not important here i'm going to make sure my application stays in the global space i don't want to add anything to the jira application spoke and then we're going to make sure i'm not going to put any protection on this but we can use some categories to group our subflows and as we reuse them we don't want to be able to find them so that's what bats are for we'll go ahead and submit and this one this example i'm going to do basically what i want to do in this subflow is it i want to create an issue in jira but in addition to creating an issue i want to put a comment on the issue engineer saying that it was created from servicenow and then i want to log in servicenow so i have an audit drill that initially was created in jira for whatever workflow that called it so that's three steps that we're going to put into the subflow and we'll be able to use those in any workflow so if i had 10 workflows that all needed to create issues they could call the subflow and we're only going to ask them for three pieces of information you saw in the action there were seven pieces of information that the um it needs in order to process it but doesn't need seven just the mandatory ones so you see the project key the summary uh the issue type is required and the priority we're just gonna pass three things we're gonna pass the summary the description actually that's it just two things we're going to pass two variables summary and description and we're going to put the prod project key within the subflow so that people who are using this upload don't need to know the project key it's not really something that's visible people just know their project names in jira so let's go ahead and set up those inputs we'll do summary and that'll stay a string and we will make that mandatory because we need that and description and that'll be mandatory as well because we need that in order to complete our flow the next thing we need to do is pass back any outputs that came from that action so we definitely want to pass the status the error message and the issue id back to the workflow that calls the subflow that we're creating so let's go ahead and specify those outputs now status and i'll have to look again status error message and issue id i'll just copy that over here and we'll add one more this uid is the id of the issue in jira of course there we've got all our inputs and outputs defined and now we can get started on creating the actual steps in this particular subflow the first one is going to be we're going to create that issue in jira and to do that we're going to use the jira spoke so top over there to jira and there should be a create issue action that we can use now you can hover over these little icons to see information about how to use them what input is required what error messages you might receive i'm going to click on it and it's going to bring up a small little forum that has those inputs that we saw that were defined in the actions this is what it looks like on the other side when you start using it so we're going to use the connection that i've already pre-configured that connects to the service now our jira instance we're going to select the project key i'm going to use my demo one then i'm going to particular pick a particular task type so or issue type so notice this actually came from that project so if you have any products up there you can get them we're going to create a task and for my summary that came as an input so notice above my head on the right hand side here i have my summary and i have my description so i'm going to click and drag the little data pill over to summary same with description done so no matter what calls this i'm going to just pass on through the summary description and create that issue we won't set a priority on this one we'll just let it stay to the default done now i've created my issue next i want to create a comment i want to put on that issue that i created in jira just as an example for you know kind of chaining a couple of steps together let's add a comment to that particular one so add comments when we add a comment one of the inputs that's going to be required is the issue id well guess what we know the issue id because we just created it here and now we have access to all the data elements that are part of that issue being created so let's go ahead and drag over the issue id and the comment we might want to add is this issue was actually a task i think so let's say this task was created by servicenow done now i've got that documented and i've got my issue or my my task will have a comment added to it last thing i want to show just as another step if you wanted to do it in the servicenow system i can log messages those messages messages can be informational it can be warnings they can be errors this will be informational but you can see there are the different options and we're going to say issue and we'll go ahead and say the issue id was created in jira done so we've documented that that particular issue number in our logs for the servicenow platform that that was done the last thing we need to do when setting up a subflow is assign the outputs so in the beginning we actually specify we're going to do a status error message id error message and issue id as the output of the subflow for whatever workflow calls this so the last thing is some flow logic to assign subflow outputs and it's just above my head here there's a little plus sign you can see right there we're just going to go ahead and add those outputs we'll do status and that's going to come from over here status and just drop that over we'll add another one for error message and we'll just grab the error message drag it over and the last one is going to be the issue id and so we grab our issue id right here drag it over and click done and that's it so we go ahead and save our subflow and we're going to test it after we save it to make sure it's working like it's supposed to so go ahead and click test and we're going to say let's just say testing subflow capability with jira paste that down here in the description and run the test and once that runs we should see a issue get created in jira the comment get added and we can move on to do our workflow so we'll hop over here to jira i'm looking at all my issues i'll just go ahead and refresh and see if we've got that one there it is testing subflow capability with jira open that up and here we've got our description or our our summary our description just like we did it there's the comment that got automatically added so our subflow is working like we want it and now we're ready to move on to the workflow piece

View original source

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