logo

NJP

ServiceNow Jira Spoke: Project to Project Pt 2

Import · Aug 17, 2023 · video

[Music] all right [Music] hey everyone it's Justin thank you for watching and welcome to my house that's Justin's house in this video we're still talking about the jira spoke and now we're going to complete part two of syncing our projects to jira projects by using the update action so if you haven't watched it check out the previous video I'll include a link to it up above but in that video we were able to create a project in jira which you can see here leave of absence no work authorization we use the project number as the key we set the project lead to myself and now we need to basically do the same thing but as a update instead of a create and uh what we're going to do is complete this section of our flow so in this section of our flow we're checking to see does the project in jira already exist after a project in servicenow has been updated and if it does we want to update the project in jira so maybe the name of the project change maybe the project manager change we're just going to do the name to keep it simple but you can add other fields in order to do this update process and we're going to steal from servicenow let me show you why we need to steal if I go to add an action to this particular flow and we look at the jira spoke we won't see anything for update project we just got create project and a couple of others I'll show you here in a second when it loads all right just load it up there I'm not going to lie to you sometimes these things take a hot minute to actually load I know there's supposed to be performance improvements in Vancouver I'm still seeing some slowness in some of these so I wouldn't rely too heavily there are some performance improvements but not around everything but here's the project management piece where you can see I've got create project look up project look up projects look up project stream and look up users assignable I know how to update projects so we're going to steal from this create project because it has everything we need when we created our project so let's take a look at that create project action that we're going to copy here it is this is what it looks like we've got inputs a connection info steps some pre-process using script an actual rest call and some error handling I'm going to keep it simple in this video we're basically in a copy of the rest up and have some inputs and that's it and we'll probably use these same inputs now what's cool in flow designer with an action you can take something like this and just say I want to copy the action I want to take everything with it and then I'll remove the stuff that I need to do now you want to make sure you do this in the right project scope I'm in my over the right application scope sorry I'm in my application called Justin's house you could do this in the jira spoke application or you could do it in another scoped application I suggest you do it in something separate from the spoke that way when there's changes that this book there's no conflicts or anything so I'm doing this in Justin's house just for that reason we'll call this update project instead of create project and there below you can see my application scope where I could change this if I wanted but I'm going to leave this to Justin's house we'll hit copy and that will open a new tab with my action and then we're going to modify that to update the project now I'm going to skip some of steps there for pre-processing where it's doing it's like basically assembling a payload looks like Max you can't see this error message I've got a max length exceeded in two pre-processing for field server type so it looks like in step two server type something went wrong there and trying to copy the action but that's okay we're not going to let that stop us you can see there's some scripting and stuff going on I don't want to do anything nearly that complicated and since we can't copy it we're going to have to create it from scratch which is fine so I'm just going to come up here I'm going to go to new action and update project and we'll keep it in the same project scope that I told you before and it's already been created okay um well if it was created Why didn't it open all right so let's delete that and let's close that window and we'll go here to actions it must have existed but maybe it just didn't create everything we'll find out here in a second when the actions load so I sorted on create or I searched on create project we'll just search for update project and yep it does exist it's in my application I hope it has some stuff in it and it does it has everything I need so this is good so we want all this stuff because this is a stuff that could change um well the key probably won't change but the Project Lead the description stuff like that might change I forgot about the description um we we can get the connection info this is going to pull in the connection and the credential Alias which will pull in the connection and credential to actually connect to our viewer instance so it's okay to keep that stuff we're not going to need this pre-processing step so go ahead and delete it we're going to assemble our payload within the rest step and I'm going to get rid of this handle errors error handling is something that you know you you definitely want to do but we're not going to use servicenow's scoped jira Handler your error Handler I don't want to get into all that in this video so we're just going to delete that step and keep this simple so we got our connection info and we've got our create project rest up I'm going to rename this to update project so I'll just make step number two update project we're still going to connect to my base URL my instance all that's good I'll have to blur it out but that's okay and we have the resource path right there this is not going to be a post um it's going to be a put right so the post would be its new project um put is going to be an update to that so we're gonna do a put and everything else is going to stay the same there and we're going to come down here uh where's my payload um I was expecting that to actually change and let's see we've got request context um maybe let's go back to this one here maybe that's what didn't come over um Let me let me uh let me get out of this real quick and I'm going to go back in and make sure I didn't do anything to change that I'm gonna make sure that section's empty because the request body should have had the payload from oh it may have deleted when I deleted those steps you know what um that's okay we learn as we go or that's how Justin does I learn as I go well let's go ahead and look at that rest up again before I delete anything yeah yeah okay so it had the step for the payload that was coming from this pre-processing script and I bet you when I deleted this I'm going to go ahead and delete it because I don't need it it's going to then to delete that from the thing that's that's what confused me is I've already gone so okay that's fine we'll just delete this again um you didn't lose that many seconds of your life let's go back to this create project everything looks good there except we do need to change this to a put and we need to change the request body text maybe wondering how do I know what body text they were doing this fancy script would I do well we ran that flow earlier where we created that project and when you run a flow you can go look at the execution history for for that particular flow that we ran even though we're testing it still has an execution history that's going to pull up here in a second all right that's another great example of how there's still performance issues that took a couple of minutes to actually load um this was the last one I did where I recorded my video so I'm going to go ahead and open that one we can see the history of when that ran and what I'm interested in is this create project step right so we have the create project step we can see where it ran and we can scroll down and see the different steps and we were just looking at the steps there's that good at connection info there's the integration metadata step connection or the pre-processing script and then we have the actual rest call the actual rest call has that body text right there it's no longer a data pill it's actually what we need so that's the what we're going to try to put together in our new action for update we're just going to copy all that and I'm going to put that in my new action so let's go over here to the update project action scroll down here to text and I'm going to paste that in so the key is actually going to come from the input so remember our inputs here are the key the name the Project Lead account ID the Project Lead description so we're going to do all that under the oh and I need to rename this I renamed it before I started over as an update project there we go and then we'll scroll down here and so our key is going to be that project number so let's just delete that one that's hard coded in there and we'll add the inputs and the key so there it is the description is going to come from there as well so let's just close that out and type in the inputs and description and the name same thing this is kind of getting dull and boring but this is how it works we'll just put in there and the description the project type key we'll just leave a software and the lead account ID we're going to change this right here to the inputs and Project Lead account ID and that right there everybody tells me I do not need to fill in this project lead I wasn't sure that it before because it was just a display name is what I put in there but we're just going to put in the text for that so now I've got my fields in there so if I do an update it's going to call this it's going to ask me for the same information that we got asked on the create projects but we're going to just do an update instead so I'm going to go ahead and save this and in order to use an action after you've created it you have to publish it I want to test it first it would let me know before I go through all the effort of adding this to my flow so let's go ahead and test it my project key is over here so we'll just scroll this way so we have both on the screen Oh by Mac is hiding it okay you're just gonna have to trust me the project key is prj0010018 and we'll just go back up here and we'll change the name of it so the previous name was leave of absence no work authorization I'm gonna change this to I can't copy paste it because I start it I'm clicking on my other screen here bear with me there we go copy and paste there's a leave of absence no work authorization and let's just change this to modified so we see that come through project count lead ID we're actually going to get that from oh man it's going to be in that flow history behind me so we're gonna have to cancel out of here and go back into there and grab that account ID it's right there there we go so let's go back to our action here we'll test again and of course it didn't keep anything but that's okay um project key is prj0010018 and the name just focus over there when I put this in the wrong field put that up there so I think this can be anything we'll just put in your test see what happens and we'll put in here modified like we had before and the description we're going to say we are updating the project right and so let's take a look at that project in jira that's what it looks like um there's the project the leave of absence project we can go back to it and see all the information about that project let's go to Project settings um there we go there's the description there's the name there's the key so you see it all there so this should change if we're successful in testing that step so let's go ahead and hit that run test button and if we've structured everything correctly it should go ahead and update the project we'll find out here in a second it is all done so let's go ahead and I will click back on here and there it is and let's just let's just go to a different page and come back to the project details and see if anything changed okay it didn't doesn't look like it worked let's go back to here and click on that see if we got an error message we did so not equal zero is not a valid conditional expression where was that expression uh there's the get connection info that all worked here is the rest step mandatory there's my body method failed with code 405 spawns headers that's pretty useless so this isn't working ah okay so I see where I made the error you probably saw me doing this on the screen notice there's no quotes I think this is the problem there's no quotes around my stuff and um yeah it actually has the name wrong too so I'm glad that didn't work all right let's go fix that real quick uh let's close that cancel that and let's get back into this rest step scroll down here and let's start adding some quotes around this one I'm hoping that's what it was because definitely the Nita quotes around there because I took them out so this is the description oh I did actually add the wrong thing it said look I have description for the name that is incorrect let's go ahead and get rid of that this is great you'll see an example of how it is to actually work in service now I am not a genius I don't know everything but I know how to fix what I did wrong uh there's my project name in quotes that's good and we'll change this lead account ID to that and have quotes around that okay good stuff there that's all done let's save that and we'll test again and see if that updates our project correctly this time now that my request body regular request content is formatted correctly so oh goody I get to paste all this stuff again and we'll put in that lead account ID we'll just put test there the rj00 and let's go back to this one select all that name so it's zero zero one zero zero one eight is our project name or project key zero zero one zero zero one eight zero zero one zero zero one eight and our name and we'll just modify that modified and then the description we're gonna put we modif we are doing an update exclamation point run test all right so I'm crossing my fingers and crossing my toes and this is gonna work let's just hedge our bets here and see if this looks any different I'm going to move away from that and come back and see if that changed and it didn't so I probably got another error message which is okay let's take a look at what there was this time not equal zero is not a valid conditional expression happened again where is this error message go to error okay so it's right there I'm not seeing it either error code one method failed with code 405 let's just uh jira code 405 so it's not liking the particular method I remember I did a put not a post um so let's go to the jira API see if we can find some documentation on this rest endpoint for projects um to your API paste that in yeah use it to get an update and so post would be get all projects create a project as the post that's what we saw earlier I don't want to do that I get recent projects get projects paginated get projects update project is a put so I was correct it is a put um why doesn't it like that we've acquired administrator permission which we have and it needs the project ID or key as a string path or printers project ID or key so is that what it was over here let's go back Andy am I reading that right so in their example so I need to put that in my URL is that what you guys are seeing let's try that interesting uh Slash project and so I'm going to put in the key right there in the you are in the resource pass that's in the resource path that's what I'm reading so put rest API to project and then the key and then in the body I'm going to have the key again it looks like but that's okay all right let's try that out let's hit the save button and we'll test it again not what I've never done before I've never seen the key like that in the URL but let's test it oh goody good thing I copy this uh there and name we're just going to call this view project name we can keep it simple and Lead account ID is actually this thing uh right there this is not going to keep this test and let's put the actual prj0010018 well as that and updating a project and we'll run the test we'll go back to jira and let's just move off of this and move back I'm waiting for that like Grand moment to where it actually worked yes it actually worked I got my grand moment so there's the new project name um there's the new description on that so it actually worked um exactly what we wanted so I just learned something there and that the URL we had to change in order to get that to work everything's good let's just click on this for uh Giggles I do have I still have an error on it but it actually worked um so I'm not sure why I'm getting an error action status oh this is probably in the action configuration okay I'll show you where that is in a second we'll get rid of that error so everything was good there and I got um a successful response from that so everything yeah everything came through good and we saw that it actually updated so let's close out that and let's get rid of that error message let me show you it's probably here in the outputs or in the error evaluation yeah so action status code remember I deleted all the error handling so I just need to delete all this error handling from this section as well since we're not going to do any of that in this step and then we should be good um let's just be thorough test this one more time and here's my key over there copy put that here and we'll call this um it worked project name and or the key sorry it's key has to be prj-0010018 and the name and this is the second success with hopefully no errors and that's the project leads name we want to change that to you um Bernie I don't know who Bernie is but let's just do that we'll run the test all right let's finish let's head back over to jira and go back here go back to the details and it worked project name this is the second success okay everything's looking good there even has the Project Lead as me even though I had a different name in there because that's using the ID let's go and see if we still have an error message and we don't no error message so we're error free so guess what we're gonna do everybody we're gonna take this and we're gonna publish it and uh please correct the following errors great action output ID empty output value cannot be blank on the publish so I thought there was no action outputs let me edit the outputs there it is um projects I don't need to do I want no I don't need that I'm just going to update it and so let's just delete that there we go I don't need I don't need to send the project back because we already know about the project in um as the project record because this is an update step in the create step it's important to get the object back because we don't want to do things with it like added as part of the project record but we don't need that here so let's go ahead and publish now and now that that's published we can use that in our flow now this would be a good test for Vancouver do I have to reload this flow in order to use that new action we will find out so let's go ahead and replace this placeholder activity with my new uh I think it was in Justin's house that's right I put it in that application to Justin's house we should have our new update project which we do I didn't have to refresh the browser that's great there's my update project my key is actually going to be in that project record so let's go to the trigger and I have the key in the correlation ID um actually I have the key as the project number so I just use that project number right there the name is still going to be the name so we'll choose the project name everything else would be pretty like the last video uh I think it's project name not name I always scroll past everything I need the lead account ID oh this is interesting so that's going to be that stuff below where I had to look up the users and all that mess so I don't want to do this anymore I actually want to fix the way I do this I'm going to make another video where we fix the user situation here because I didn't like how that turned out so for now I'm going to cheat in this video so that we don't have to make this any longer than it is we'll just paste in my ID there we'll come back and fix that later the name will just use uh the my actual name let's see project manager and then we'll go to my name there it is and the description is going to be the project description so if everything's good there that should be in the D's description and we'll hit done we'll hit save and what I'm going to do is I'm going to go back to that project the leave of absence project and we're going to change the name and service now and see that all that goes through to jira so let's go to our project table PM underscore project dot list that's my shortcut from not having to go through all the menu items to find that there we go leave of absence should be right there let's go ahead and open that project up and we're going to change that name we're going to change that description and then we're going to go test our flow because our flow isn't activated yet our actions activated and published where our flow is not so we'll call this leave of absence new work authorization um let's just call this leave of absence demo for YouTube just like that and we'll change the description to testing out the updated uh project action for jira all right so it should look very different from what we tested with and we'll know if that actually works let's hit the save button there and we're going to go test our flow and that'll wrap this video as long as there's no errors we'll search for a leave of absence demo for YouTube there it is and because in our flow we're actually checking to see if there's already a jira project created it'll hit this first step and never execute that create step down here below if there was no jira record associated with the project it would do the create like we saw in the previous video so it's one in its flow it's all finished let's top over to jira and we'll just do the same thing we'll move to summary move back to details and see if our project information updated and look at that they're updated leave of absence demo for YouTube Down Below in the description testing out the updated project action for jira everything updated like we expected using our new action and using that flow so everything is good there what I want to stay tuned for in the next video is we're going to clean up this flow and the user situation here and then I'll have a solid project to project flow so it'll be a part three where I set up the users but in the meantime I hope you found this video helpful if you did please like Please Subscribe or share with somebody who you think might be interested in not just creating projects into Europe but keeping them in sync and updating Nigeria when things get updated and serviced now and until next time don't forget to always be learning thank you

View original source

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