logo

NJP

ServiceNow GRC/IRM: Full Flow (Part 3: Issues)

Import · Oct 06, 2020 · video

okay good evening welcome to phil goes deep this is part three of grc full flow so we're going to be continuing to convert the servicenow grc application grc which stands for governance risk and compliance into flow designer so far we have converted some of the apis from the indicators and now we're going to move over into the issue management side of grc both of these areas are within the grc profiles application which is central to policy and compliance and risk management so therefore it makes sense for us to start in the middle and kind of break it out from there that is the plan i will start to share my screen but i just want to say shout out to travis tolson for sharing the links and sharing the channel i've got the subscribers up by a pretty fair number thanks to you travis thanks to everyone that has subscribed and out to anyone that is listening right now i need to apologies okay apologies that was a technical issue of the four-legged kind so that should be sorted tonight i have got just under one hour to try and do something more i'll just let people know if anyone's watching you might be in for a shock from thursday onwards i'll keep you posted on that right now i'm going to get into it okay so this is the uh the drawer draw i o plan i've got for converting uh grc into flow designer i've got here down here as my starting point so any api calls we find we'll review them identify any public methods turn them into actions then we can create flows subflows and replace all of the calls i've put here embedded code because this might be something that's hidden within a business rule for example um what else oh yeah the plan overall or at least the scope of what we're doing so within grc profiles which is the sngrc scope we have so far focused on indicators which i'll just call this indicator engine the fact that it's base so the indicator engine uh we found that there were some methods in here run all indicators run indicators these have been converted the scheduled job's gone over the ui action has gone over the script action still hasn't actually been tested but we'll get to that then we went through table by table uh one of the things i found and you'll notice here before previous delete these areas are not immediately or at least obviously available within flow designer but if you check the link in the description you'll see i've got a link to the servicenow community and i'm trying to report my findings in here what i have found for business rules now that before and delete operations might not be available as triggers in flows so if you really did want to move them into flow designer and the benefit there could be a ability to debug then you can actually trigger it in a business rule and then make that business rule call the subflow okay so there's some potential workarounds the previous objects not available so potential work around here could be to trigger from the business rule and pass in the previous object explicitly as an input when building actions from business rules embedded script with no return value um in this case and what i've said here as part of this series at least for the the beginning is to try and do it like for like okay so i don't want to try and what i call improve things if i break something along the way so i want to move it in as is but there's a potential here for at least returning the output anyway i think that would be beneficial when you start to debug your um flows subflows actions you've got a return value it's going to be nice it's going to help and then from there you can probably do a bit more with that option so um yeah that's that's where we're at so within uh indicators what we found in here that these two close or update issue and create issue when result fails i wasn't able to convert these because issue or at least the issue utils api hasn't been converted yet so i'm going to move over into issue utils i'll try and keep track i know my design diagram is a little bit ropey at the moment um while we're talking about debugging um let me just give a little shout out to steve yeah um i have got a lovely mug here and i don't know how the lighting is on that but if you can spot the deliberate typo in there um the first person to spot a deliberate typo i'll get someone to steve maybe i'll get someone to buy you a coffee i think that's the rules okay back to it my instance i have got a and i can't quite see my screen i have just obscured the the address bar but i've got an update set set up for the full flow project grc profiles is my scope so what i'm going to do in here is just hit up script includes and we are looking if we look at under application grc profiles apologies for any typos in here as well the way i've got the microphone actually obscures the keyboard so grc uh we actually want issue let's just do asterix issue okay so we've got a couple of things under issue we've got issue grouping including ajax ajax is a question i think let's move into a new page for issues so i'm going to put a question mark in here for ajax i don't think that blows him i don't think that belongs in flow designer i'm not going to focus on that right now let's turn this blue to show that we're working on it and issue utils issue grouping so i think issue grouping and issue utils are really going to be where we focus our time issue utils issue group him another shout out for everyone on uh getting ready for now at work virtual event okay i'm sure we'd all love to be in the presence of each other right now but it's not possible so hopefully everyone's taking the time to at least attend some of those events i see what's going on i think now work london is kicking off tomorrow and then we've got amsterdam shortly afterwards check out all of the uh events from the servicenow website follow servicenow on linkedin and you will stay up to date i'm sure issue utils we're going to the base because we haven't overridden anything this is an out-of-the-box instance i'm running on new york as well by the way the plan i will upgrade to paris um in a couple of weeks or at least around 10 10 days ready for the new new release of the grc apps so i'm running on new york but i will get onto paris very soon what a little green tea there but it's fresh out the kettle that's a bit hot so let's look at our open methods you can see that we've got one two three four five six seven eight nine ten eleven not open public methods okay so we've got eleven actions to create let's go into flow designer and i was thinking that i have created a category called full flow but perhaps that should be called indicators and then i'll create a new one now for issues so if i go new action and my action is going to be called find existing open issue see my category i need to change scope grc profiles so if i go to this category i'm going to call this full flight indicators for the existing one okay and then create a new one for issues just because it's going to get a bit busy and flow designer actions otherwise just want to check as well issue utils available from all application scopes that's good find existing open issue so when we initialize issue utils we don't pass in anything on the initialize but when we find existing open issue we do pass in the item now item in grc is referring to the sngrc item record which is extended to the sn compliance control and sm risk risk so when we see item we need to think control or risk okay so my action input is going to be item in fact let's call it uppercase item this is going to be a reference to sn grc item note item generation reference to control or risk okay got been named and that is mandatory do we return anything in here yes let me copy this into code so find existing open issues go to definition going to return the issue record which will be actually a glide record which is nice so therefore our outputs will be let's call it issue rec just call it issue and this will be a reference to sngrc issue table i won't make that mandatory because it could return null okay this is find existing open issue okay and grc is not trying to constantly create new issues every time something goes wrong it doesn't just create a new issue it looks for an existing issue typically based on the control or the risk it says i've already got an issue here let's start to stack things up and then on top of that you've got issue grouping so issue grouping then says well based on the rules you've got so based on the manual request to group these issues then i'm going to give you some hierarchy around your issues so that you know perhaps as a control owner you've got one main issue and then all of your child issues are more specific okay so issue issue management generally is is trying to reduce the the number of different issues and avoid that kind of proliferation so if you notice this is called find open existing issue in my script step i'm now going to rename find existing open issue and make this a little bit more friendly my input variable is going to be item item yeah item there my value will be item from my input my output will be issue which will be a glide record sorry a reference it sometimes this does feel like duplication i do feel like i'm repeating myself and then we have to map here oh value yeah if you that doesn't make sense just rewind here we need to instantiate new issue utils dot new issue utils find open existing issue inputs dot item and outputs dot issue oops autofill output.issues outputs dot issue equals it did this last time on a previous one and i missed the new constructor offer there so outputs.issue which is my output here equals new issue utils let's just make sure yeah issue utils dot find open existing issue find open existing issue passing in issues.inputs.item boom boom boom okay let me just save this and if i go to the instance and look for issues all issues big splash i like the name of that one hopefully the demo data doesn't let me down here so this item is called records management we've got control number there so it's records management if i test this no records management oh dear loads of them i'm going to tell the two apart when we're testing i don't know what order that's in either records management i've gone to the top one sales for sale cloud so let's go to controls records management sales force i'm just going to create an issue against it how's that and we'll have an open existing open issue full flow against the control risk therefore when i pass in the item run test action's been executed completed successfully and we have got we should have an output output issue reference says it completed successfully but i'm not seeing not seeing an output there find existing open issues so i passed in there definitely got an open issue i would have expected to see that issue let's see if we can break that step down item records management salesforce cloud so if we open that record let's just double check yeah it's got an issue the one i just created output data reference so my input is an item output step issue so let's find out maybe let's say far gr issue equals and then outputs dot issue equals i wonder if just breaking it into a second step will help we said records management first one in salesforce run the test i don't seem to be getting any output in there that's confusing me let's see what happens if i did just change this type to a string and you know i would typically change that to issue id ah now that's still showing that's looking like a reference even though is that what it is let's see reference i think let me just save that maybe when i save this i didn't go back and set there issue let's just test this and see if we can figure out what's going wrong if i now get an output no it's still not getting an output which is a bit weird that let's change that to a string save my string output action output edit the output say that's a string still not getting any output in there why am i not getting any output i'll tell you what we'll do let's call that code let's call that code directly so if i say from this control and open in explore that gives me a lovely glide record then i can just grab the code in here so i say new issue utils dot find existing open issue gr reference error of course sn glc i wonder if that's the point that's giving me a null okay so maybe my actions working let's just change scope yeah it's not making any difference even though this control has got an open issue on there go to the script include find existing open issue just hit up script debugger run this script debuggers caught it oh dear sorry just realized realize what it is debugging yeah being the detective in a crime crime movie where you are also the murderer that's exactly what i am right now the detective and the murderer look at that created manually i created the issue manually so therefore it won't find it so watch this it's going to go if next and skip that right you can't return it because there isn't one it's going to run the query it's not going to be next i'm going to return now is my bad it's a data issue i think my actions absolutely fine so what i need to do for that control weird how that is showing up in my my navigator that's unusual okay let me return this to draft and i'm just going to take it out of the control objective save that grc attestation and put myself in there now i test it i'm going to get an attestation my attestations and this one is the control implemented no create me an issue okay if you notice this bit at the top here this is table titles okay i'll try and put a link in the description or share a link to the community article someone brought this to my attention out of the box way to provide additional information into the attestation very very very helpful submit that now my control already had an issue but now it's got two issues okay and if i go in here created manually that's the other thing about issues if you create a manual issue then the system cannot handle that systematically okay so my issue up here full flow is created manually i'm just going to delete this okay because i created it for demo purposes and all that's done is cause me problems okay so this created manually false that means the system's automatically created here which means that from the issue utils api perspective it can it can work with it i'm going to run this test straight away and look i've got an issue but i'm passing it back as a string now so i need to go there's nothing wrong with my action in the first place but sometimes it's nice if you just string stuff and you know for sure what you're dealing with change this back to a reference or sngrc issue table yeah confirm that change and then in here i'm just going to go back to shoot from the hip i don't want an extra line of code if i don't need it if anyone's struggling to read that you probably shouldn't be changing it okay reference to issue reference to issue save that have i mapped my output no map that back in save that test it again records management i hope this is the same one because i did remove the control objective is it for salesforce yes run test boom and now i've got the issue and it's a reference 2023 2023 okay excellent so find existing open issue converting that has only taken us 32 minutes with a little bit of preamble but i'm still registering that as a success okay find existing open issue you're going green done the next lot should be a bit quicker so get issue source so we start sprinting through this get issue source new action boom get issue source we have to switch skype every time why can't this just know what scope i'm in that would be nice this is issues accessible from all scopes so i'm just going to come in here and create a script step just give that the right name get issue source parsers in issue source what is issue source go to definition i know this is going to be new issue utils dots yeah issue source and that's going to be input stock issue source okay so my name is going to be issue source my input up here is going to be i've done this slightly the wrong way around my inputs can be called issue source and this is going to be a reference and i think if i took my head this is a reference to sngrc choice i can't i've lost my i can't see you sngrc choice that's what i think it is let's confirm get issue source sngrc choice by name okay so it's adding the query by name so it actually is it's a string it's not a reference i you know naming standards in variables very important issue source here for all we know that could be a glide record could be anything but it is a string of name okay and that value's going to come in here as a string that's going to come in there is it going to return return source yes output is going to be i feel like i should be called choice okay because that's going to be a reference to sn glc choice table and then my output is going to be choice reference to sn grc choice i'm going to map oh let me save that output there we go now i'll map that in there boom boom outputs dot choice equals save that what the types of indicators issue sources indicator let's have a look sn erc choice dot filter and then run on set is issue source indicator that's name indicator so if i test this and say indicator what we're going to get and get a reference to choice that's working okay so how long did that take i was like four minutes just going to give this a friendly name get issue source save that i'll tell you what i didn't do on the last action i didn't publish the last action so i mean let me get that done find existing open issue let me just publish that because we tested it and it works find existing open issue and we've done get issue source done done done well i need nine more to go generate issue this is a little bit more interesting okay because generate issue is a lovely api and if you are ever going to generate issues yourself systematically through the system uh through code use the api okay because this api is really taking care of a lot of stuff if you start writing your own kind of glide record scripts you are not only wasting your time but you're opening yourselves up to error okay if you look at the way this generate issue takes care of things you will see that it's not just this a case of just inserting a glide record okay i've got two inputs here i've got fields which is an object all right fields well i don't know how objects work add child item it gets a little bit messy there so let's find out if we create an input it's called issue source and is that a string let's go to generate issue issue source this get issue source which is the code we've already seen so that's the name that's a string mandatory mandatory can't do anything without them what do we return the issue we're actually returning their assist id okay if we return cloud record insert we return id of the record we're not returning the record itself so this is going to be issue id that's a string then we need a script step in here and this is going to be very simple of new issue utils dot generate issue input stock fields input issue source and then here it's going to be outputs dot issue id equals new so that auto corrects a bit wrong in here and i'll really just i want this proper script formatter in here so my input is going to be fields and issue source and that's going to be fields that's going to be issue source output issue id yes cool cool cool output issue id equals issue id why are you not liking that there we go issue id equals issue id output issue id equals however input fields object let's just save this i don't want to lose it i haven't created a flow designer action that takes an object as an input an object's one of my favorite data types in javascript i'm struggling to use them um i think always trying to use them to their full potential but when you look at the rest schema or schema api rest json schema api json schema api what is it is it this one jsonschema.org i think this is it if you're building an api and look at json schema then i realize how many of the objects i've created in the past are not really consistent and not i'm not conforming to that standard so always kind of looking at my objects and thinking you know are they what they should be um i guess looking at this fields as an object here i've got the ability to add a child item i suppose if it's always going to be the same then i could do this but the beauty of the way this script is written fields um this loop here i love passing in an object to create a record okay so we know what the table is going to be and then for each then if it's a valid you know using get element if it's valid then we'll set value look at that i mean it doesn't matter what you pass in the function structure doesn't change so there's no reason to do it differently i just don't know how to test it so if i want to create see what happens fields i don't know how to test that what happens if i put a child item in there and then test it yeah you see that's not that's not great but if i just test something i'll go to subflows execute indicator if i say test this indicator record no if i go to a flow i don't know which one it is if i say test just click the plus button and that's creating a new record there is the option to pass in that changed fields which is an object so i'd have thought that i had that kind of interface why can't i pass in fields hmm that should be mandatory what can i do in here i'll create structure manually start from template kind of template is this advanced options if i say create structure manually then you can save it as a template so if it's just a template the types of fields that are going to be okay so the the name the key value the key property of each object is gonna align and this is the beauty of it if i go to smgrc issue dot config it extends planned task so item makes it specific can't really enforce a reference can you because it would be no yeah so you can't pass in a reference so that can have to be a string um then you've got item profile trying to think what else from a short description just pass that in that's a string description recommendation let me save that as a template and call this issue i've never saved the template either but let's just save that and this is mandatory but you can't make that mandatory you can only make this mandatory start from template okay save that let's just test it fields so if i go back to my control there you go control there you can see for looking let's just copy the sys id here paste that as the item say testing full flow action generate issue this is my description lots of info not multi-line recommendation fix up book sharp so my issue source would be because i know that one is the name that exists if i run test i've no idea what's going to happen been executed completed it's passed in the object and look we've got a runtime value back so if i go to my control i've created an issue although it says created manually true that's interesting okay i've just seen an error just in an error on the stream so if you've got any problems i do apologize so the only thing that's a bit curious for me here is the fact it was created manually so we say generate issue now assume the object will take care of that then so i think that you know that works it definitely works but does that don't know how that looks when you try and use it from a flow so i'm just going to save it as an action and publish it i feel like success wise you know we've definitely done that bit generate issue but let's just explore now sorry um flow designer if i were to say create a new flow or subflow actually i've got a demo one just for playing around with if i then select that as an action under profiles i've got indicators issues that's why i changed the the category i say generate issue it's passing in fields there i don't know if i'd be better off having each of these as their own input and then using the script step to convert that to an object to pass it out to the api and then just checking if you you know if you had a blank input value here it seems like it looks like you can still pass in an object i'm not sure i'm going to kind of uh flag that as generate issues like it's not quite blue but it's not green i'm going to say in here objects as an input question mark not really sure how best to handle that i think until we start trying to connect it to flows that's going to be kind of still still a learning something we need to learn however as an action kind of effectively that's that has worked have we got time for one more eight minutes eight minutes available on the clock let's see what we can do so we've done generate issue update or create issue this is a nice one okay because update or create issue is again reusing reusing existing issues it doesn't just say let's create um a brand new issue if you've already got an issue it's going to look for that issue and it's going to pass in item and issue source okay if you've already got an issue then it won't create another one it will just add an update to it so this is going to be item and this is a reference to sngrc item which is going to be either a control or a risk that's mandatory issue source as we know issue source is a string outputs i assume we're going to get the issue id back from here let return new issue id issue id and that's a string so in the middle we put a code step script step variable going to be item issue source mapping those values to our inputs and our outputs going to be issue id string yes so outputs dot issue id equals new issue utils dot create or update and this is the input item input issue source i believe that was the order in item issue source here outputs boom boom boom then in our outputs you can map that in go and let that hover and go green but it looks a bit okay so we're passing item we pass in issue source it's quite funny we don't do an update in here so let's just see what the api is doing existing this year okay so it calls that existing issue equals find existing issue if we have it okay so update or create issue has an indicator failure it's going to update blah blah blah then it's going to add that issue source return existing issue which is issue id perfect else issue equals object so this is what i mean in this in the code i'll create manually equals false yeah so i think actually in the previous step what i should do is receive these things as specific inputs and then produce the object in this very way within the script step that will probably make a bit more sense new issue id equals generate issue unable to create an issue for i should say an issue create an issue for i think this will work it's funny that item update will create issue must only be getting called from indicators based on this api update or create issue give it a nice name save it and we should test it against records management and issue source should be indicator to see what happens when we run that test it's completed successfully and we've got an issue issue id very nice so therefore we can publish this one this is called update or create so i think on this one object as an input should hard code the individual individual input c update will create issue save that so we've done on this one i said we've got eight minutes and we've done that in five so we're really picking up some pace now update or create issue look at this update or create indicator issue let's have a quick go do one more action profiles issues go input what's going to be indicator result lovely is that a quad record though go to indicator result yes but they didn't wrap the get so this is indicator result which is a reference to indicator result that's mandatory output nothing do we get a return no return no return can't see any return in there i mean you'd expect to get the issue id back right if new issue indicator result or issue equals issue i'm curious what's actually going on here okay we pass in the existing issue find i can't really see what's happening with this okay i don't want to debug it now let's see if i can just convert it okay there's no output so i was trying to find out we want a script step and this is passing an indicator result so our input values are indicator result this is indicator result so new issue utils dot input stop indicator result inputs inputs we need an indicator result sngrc indicator i'll just grab that as the display name i'm gonna test this one of these run test i did that parcel fail it passed so actually i've got no i've got no output gone overturned values so i don't really know let's have a look what's going to do item get find existing issue for the item let's go to this indicator it's non-compliant so have we already got an issue let's just put updated on there one minute ago phil has an indicator failure was this created just now let's get back on there a second and we'll just say create it don't watch the time zones on here still haven't updated them okay so look it was created two minutes ago and updated two minutes ago so that looks like that's working however let's give it one more run test we should then get an update on there and refresh this look at that updated just now create two minutes ago and we'll see something in the activity stream activity there we go system updated just now created so when we look at that code check in it says if you've already got one yep we've already got one it's already found an existing issue so that's working so at this rate if we were to carry on oh didn't mean to do that if we were to carry on update or create indicator issue i think we could definitely get so we've done one two three four five we've got six others to do but i've really got my momentum going now definitely start creating and migrating those actions over don't forget issues is very complex there's a lot of i mean you can see there's 11 sections of the api and the reason we didn't do issues straight away is because we wanted to just start testing out indicators but we couldn't finish indicators because these two business rules make a call to the issue utils api so now we have to go back or at least in a little while that close or update issue when result passes you'll see in here remove update close one of these somewhere is going to create issue and in the result fails that will be something like generate issue or update or create issue update or create indicator issues so one of these two things is going to call existing api so once we've converted the actions in here then we go back and start plugging them in and then that's following my kind of conversion steps model identifying the api calls create the actions and then once we create the actions then we go back and create the flows and replace the calls we've got a lot of work to do but in terms of timing i said i was going to limit it to one hour once again thanks to all the new subscribers if you haven't yet hit subscribe on the bottom that's what we do isn't it yes so if you haven't hit subscribe yet please do so on the channel down somewhere down there somewhere hit the bell uh share it post add comments join the servicenow community if you haven't already join in a conversation on there add comments to the channel to the videos on linkedin if you see this getting shared on linkedin don't forget to follow all the all the recommended people in the channel as well so look out for the servicenow dev program live code in happy hour look out for the duke you know robert frederick titans of servicenow follow that series very interesting check out code creative in fact i'll just find a link of all the relevant service now collateral you can follow to try and get up to speed but if you want to know more about the service now grc community stay tuned to this channel join the community get involved in the conversation thanks everyone for watching and check out what happens on thursday if i'm streaming on thursday or thursday and beyond and i'll be sharing some other highlights other than that it's been a pleasure and stay safe everyone take care good evening you

View original source

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