ServiceNow Jira Spoke: Project to Project Pt 3 (Users)
foreign [Music] it's Justin thank you for watching and welcome to my house that's Justin's house in this video it's part three of the jira spoke projects videos and I'm gonna do the user fix that I talked about in my last video I'll link to that up here and I'll link to that video but in that video we did we've created or the previous video we've created a project in the second video we updated a project and in this video I want to change the way that I'm handling the user situation so where we left off when I did an update project I hard coded the user information into that which is never good never want to do that and for the create project the first video I did this look up all users and I had a filter on there to search for the project manager on the project record and it could possibly get back one or more users and I didn't realize that either so what I want to do to handle this correctly is we're going to actually create a table in service now and that table is going to house two things one is going to be a reference to the user table and the second will be a reference to that jira account ID and then we're just going to populate it once a day with the flow and then that way we can access it much more easier than making a call every time we need to look up a user so let's go ahead and make that table we'll go to system definition and I'm going to make the table from there I usually do things inside of app engine Studio but in this case I want to stay in this part and just get this done quickly we're just going to call this Dira users I'm going to keep it really simple zero users just like that that'll automatically populate that I don't want to create a module or anything because I can get to this using the table name there but I'll go ahead and save that and like I said we're going to have two columns in this one it's going to be a reference to the user table and then I need that lead account idea to it's a CIS ID or a good we're going to actually store that in a string on this particular table so let's go ahead and create that column for the reference to the user table all right there's my new one we're just going to call this a reference reference there and we got to label that it's going to be user and we'll add a user and then our reference specification is going to be assist underscore user and that's good there we go so we're going to reference the user and that's going to be definitely mandatory and definitely going to debate our display value for this particular table so let's go ahead and submit that and the last field that we need to add to this table is going to be the uh jira account ID so let's go ahead and click new this will be a string we just need to store that value in here so we'll do string jira account ID and we'll set the max length to 40. this will definitely be mandatory and it's not going to be our display and we don't need a default value for this so hit submit and that's it I've got everything I need to do now in order to create a new flow that in theory in production maybe you want to do once a day if you have a lot of user movement I'm probably going to do this in my PDI like maybe once a week once a month it's just me and my PDI but your mileage is going to vary depending on what your needs are so let's just go ahead and create a new flow we'll just call this lookup well actually let's call this sync jira users because that's what we're doing we're bringing the gr user information over to servicenow we'll leave this in my Justin's house application hit submit and one of the triggers that we can have for our flows is actually scheduled so I'm just going to do this weekly and we'll select on Wednesday um which is tomorrow sure 9 p.m is fine and done and then our action is going to be that your action to look up users all right here we go let's search for jira down here didn't take as long as the last time but still took a little minute and we should have a user management section where we don't have a lookup user but we have a lookup users plural which I'm actually okay with now because that means less lookup users stream I'm not going to actually filter or search I'm just going to grab all the jira users so we're going to leave the query blank and then for each one of those I'm going to see if they already exist in the user table so we're going to look up a record in CIS underscore user there we go and we're going to match on the email address so let's just type in email so if the email address is matched as what we've got in the lookup user step uh there is their email address then we're going to go ahead and create a record in that table that we just created so let's go ahead and create a record all right so if you remember we named that table G or a user so we should be able to search it to your users and that can sometimes happen all right I even put this on my clipboard so what's happening here is I've created a table in the system but I already had this session of flow designer up and running so I'm going to cancel out of that we're just going to save our work so far on this flow and I have some other tabs open at the top you can see in there I'm just going to close all those out so we don't have to refresh all that stuff and now I'm just going to refresh flow designer you can't see me I'm hitting the refresh button in my browser and because I close all those tabs all it's going to do is reload this one flow and now I should be able to go action and we're going to look up or actually we're going to create a record in that new table I'm not going to lie to you this ticket ridiculously long to pull up the menu there so we want create record let's go ahead and let our table load I like that they're putting this little indicator here so while it's like this this Square um it's still loading all the tables in the system and when it turns to something like that is when you can actually use it and if you want to make it move faster let me move my head out of the way you can hit this done and then kind of reopen it and it'll do like that where it's actually ready to go so there's a tip from Justin unsolicited there's my new table jira users we're going to set the user reference to what we just looked up in the previous step so let's go ahead and look up record there's the user record and then for the jira account ID we have that in our Loop so we're just going to grab that from the for Loop there users and then we should have the account ID and hit done and so the idea is we'll run this once a week you may want to run it once a day we're going to populate this particular this new table with that information and now when we're running our other flow that's doing the create or update we don't need to make a call to jira just to get the user information because we're already going to have it in service now so let's actually look at the table let's view the list here show list and I should have one record at least now I got a bunch and no user information oh great great so it didn't find my email address which makes sense actually um Because Why didn't it find my email address it should be in there hmm what could have gone on let's check out the history on that um no record found I see what happened no record found no record found so it never found a user record um that matched my email look up email address all right well my email's in there so it should have found me at least because we know that worked on the previous one um so it's pulling back nine nine users look up user where email is and then oh did I look up my own now let's make sure that's correct this is going to be in the for Loop data pill look up users the user and the email address so that should be valid my email address is over there so it should have found a match and it's not finding a match that's interesting this should generate a bunch of nonsense so we should have 16 records of no users yep that's what I'm expecting there's me on the bottom nope I am 5e96 so where's Five there I am right there and let's see what the history was that was like fourth from the bottom maybe it's the same order here so look up record email equals blank any of these have so that's the service account that aired out and then everything else had a blank email address so it's am I even getting a list of email addresses it's a pagination configs I can't look at the results that's annoying response body all right email address blank email address blank what was mine 5e96 there's my account ID email address blank all right I'm here a couple days later I had to work on something else so I'm gonna cut out the time in between but I want to come back and see why my email address wasn't showing up when I was doing this look up user stream the percent obviously got me a wow card to pull back more data but I still wasn't seeing what I needed so what I did is I clicked on this open Action uh link that would open the action in action designer and an action designer I'm able to test it right so I was able to test it and when I test it I could open up the execution details and I was able to actually look at what came through so this is the Json object of all 16 people right because it starts with zero yeah zero to 15 or 16 people and I notice from mine there is no email address the email address said no so I went back over to jira and in jira um let me show you where I was when I started I was on this page I just went to my user menu and account settings I am the admin for my account this is all under my email address and I noticed at the very very bottom it said contact and had my email address and it said who can see this and it was set to or admins only only you and admin so I changed it to anyone it warned me it's visible to anyone who can view your content and it's accessible by installed apps well guess what I think I know it's not an installed app but I'm thinking the integration just could not see my email address because of the setting so once I saw that I changed it and it says it takes a minute for it to do it and I was like oh I should record this and that's how I ended up here so let's go back to my test here and I want to test it again with you guys live so we're going to close that history there we're going to run the test and now I'm hoping my email address shows up in the list of results that are coming through all right here's the big moment let's go ahead and pull up that payload and see what came through for Justin and what do you know that fixed it so now I can see my email address that's what I wanted in order to create my users on that table that we created so now that I have that coming through correctly let's make sure my logic is correct for when to try this so we're going to try looking up a user record where the email is the email address and I think I wanted it where the email address isn't empty either that was important because I saw the in the table itself um they were coming back empty so let's go ahead and open up that table I'm just going to search for uh oh that's right I didn't make a menu item for this let's go to tables it's been a day or two since I did this so I need to go find that table name I'll shorten those up for you in post okay I got my table name I'm gonna open up to your users and I'm going to click view list on this and it should show me all the people it's found so far uh if I had didn't delete it the last time we were doing this yeah so I didn't Purge it out so let's go ahead and Purge that we're going to delete all of those and I shouldn't have any empty users but what I do know is true is that the jira's passing null values for email address and I know there's users in servicenow that have null values for email address so it's probably finding the first met and linking together I don't know why there's not populating an actual user record but let's see if we can work around that so we're going to look up a record um from why is that not showing done and go back into it uh not back into that one back into this lookup there it is now use this user table and where the email I wish I had is not empty all right so let's get rid of this we're not going to look for a match there we're going to look for is not empty and the email matches so it is what we see in our lookup user Stream So the user's email address so it shouldn't be empty it shouldn't be null is null an option so it's not empty and is anything contained is empty is not empty is empty string okay so is not empty I'm gonna leave it like that I think that's what I had before but let's go ahead and save that and if that's true we're going to create the jira user users record so that's the user in the table we're going to drop in the the user side of it the sys ID of the the record we looked up here and for the jira account ID we're going to drop the account ID in there so let's go ahead and save that and we will test it all right run finished let's go back to our table hit refresh see if we've had any better luck here oh my goodness finally it finally worked okay so because of those changes now I have my jira account ID linked to my user record all right this is critical critical critical for fixing our flow so if you had more than one user I'd expect this table to build out with everybody in on jira and Link them to their account and service now so what I can do with this now when I sync my jira users is um actually no like I think Nigeria users this is just gonna run right so this is going to run on a schedule every Wednesday at nine o'clock in fact let me go ahead and activate it because this can run forever and ever and ever and I don't care um if there's an error or whatever notice I left my try catch my catch is empty there's nothing happening there I don't really need to do anything um if there's if they're not able to find a record but so let's go now to my project sync flow and let's fix the user situation there in the first video I used a for loop we're going to get rid of that and in a second video I hard-coded my account ID which you never never want to do that's bad practice bad bad practice but I didn't want to make a longer video so this is the loop I should be able to get rid of now so if um else if the jira project is already created we're going to update it and instead of hard coding my ID there we're gonna grab it from that table so let's see if we can dot walk our way there we're going to go to the trigger I'm gonna go to the project record and from the project record I want to look up the project manager so here's the project manager and from the project manager I want to get to that jira users table let's see if it's that easy nope it's not that easy um let's see here how am I gonna go walk to that table that's okay um that's okay so I can't dot walk my way there because I'm not storing a reference to the jira table in my user table the whole thing here is I'm not wanting to modify the out of the box this user table I don't like doing things like that maybe you would I don't want to do that so I can't dot walk my way there that's okay I still don't need to make a rest call to jira to find that ID I can just do an internal lookup and find that idea so let's do that instead let's look up a record and we'll look up a record in that jira users table I'm getting really impatient with that loading the actions it's like ridiculously long okay but we're gonna look up a record here and I'm gonna look up a record in my jira users table so there we go and we're going to set where the user or the assist ID is not sysid sorry the user jira account or its user there it is user uh we'll actually check the assist ID so the assist ID for the user that's referenced in that table matches the project manager's sys ID so let's go on a project manager and they're close close close close close close gosh darn it I wish I get there faster you know I could type it in and sysid it should be before the teas there's this ID so we're going to look up in the jira user table where the sysid matches the project manager and then when I'm updating the project I can use step number three step number two lookup record jira user's record and grab their jira account ID and put it in there okay that I fixed that you know not mistake I did it on purpose um because I want to save time in the video so that's good let's save that and the next thing I want to do is fix this Loop down here when there's not already a project created I'm trying to get away from making all these rest calls every time a Project's created or updated to look up user information so I definitely don't need to do that but before we create the project let's go ahead and do the same thing we did here in fact let's just copy this action we'll duplicate it and then I'll drag it down to above the create project so now I'm doing the same thing there didn't have to reboot me that and that will just get rid of this for Loop and when we create the project and when we set the Project Lead account ID we don't need the flow variable anymore we're just going to go to step number five look up record jira uses record and grab their account ID for the Project Lead name I don't need that anymore now we know it's actually useless if you saw my other videos but just for fun we can go to the trigger the project record the project manager and just grab their name from that field project manager and then scroll down to their name this will make no difference what to allow its account ID that actually matters that that happens so now that's done let's clean up our flow variables since we don't need those anymore so I'm going to delete the lead account ID and the Project Lead name used in action three and six that's fine close what was three update project project lead okay so we'll just do the same thing there to look up the project manager's name there we go so we've got it out of step three step six I think I already took it out of uh I took it out of here again so let's put it back trigger project record project manager and project manager name which is right here which is me alright so done um and then the update project record that should all still work the same step number six is to create project ID so when you when you change the order or you add and insert steps you want to go back through your flow and make sure all these numbers are still accurate right so this doesn't say four or something crazy I've seen that happen before haven't had it happen since I upgraded but you never know and this is the project URL so that's good so everything looks good there we are ready for our two final steps of this third and final video of how to sync your projects to jira we've got a better user situation going on which I'm happy about let's go ahead and activate do I want to activate this I'm going to leave it inactivated because I really don't need this running I'm just showing you on how to do this but let's go to a project I'm going to actually go to the PM underscore project table dot list and let's find a project um that we want to go ahead and sync so let's do Recycling and waste management I'm going to change this to Justin Meadows so that that syncs over uh hit that and that should save the project we'll go ahead and open it because we're going to come back to this and change the name and everything but right now there's no dear project for recycling and waste management let's just double check the facts on that one uh we'll close my account settings and go to jira software I think it is and then I should be able to see all my projects already on all my projects so there they are leave of absence is the one we've been demoing but now we're going to do this new one so let's go back to servicenow and Recycling and waste management we're going to run and test our flow for recycling in Waste Management this first time we run it since that project doesn't exist in jira it should do this else box down below because it doesn't exist so it's going to create the project in jira that's the expectation there let's go over to jira and see if that has happened yet even though the flow is still running I'm just going to hit Refresh on this page and it did it's already there Recycling and waste management we can see the project name the key and it's assigned to myself let's open it see if we've got a description I can't remember what the description was um let's go to Project settings where's project settings projects for cycling Waste Management oh come on the settings were here last time back to project project settings all right details project description oh created based on the PMI approved project template all right it's all there so now let's go back make sure that description matches let's change this recycling Waste Management YouTube demo we're changing that and let's change the description we finally have a fully functional workflow exclamation point wants to fix that with a capital W we'll save and we'll test our flow again and when we test the flow again we are expecting that it's going to hit this section now if the jira project's already created it's going to look out the jira user record it's going to update the project um and uh oh I'm just realizing um my action to update the uh jira project is missing no or is that it right there to update your project I think that's right I don't know why there's a servicenow logo on it though that's what threw me off um and that's probably because I put that in my um own scope instead of putting it in the the jira spoke so let's just uh stop freaking out Justin and let's go look at the um jira summary your project summary we'll flip back and forth like we've been doing and see if we have it yep it updated there's our YouTube demo piece of this there's the updated description it's still assigned to Justin Meadows and everything worked as we thought it should so that is a better way to manage your users I hope you found this third video helpful and hopefully if you've done this you can go clean up the way you're managing your users if you like this video please like Please Subscribe or share with somebody who you think might be interested in syncing projects back and forth between servicenow projects and jira projects and until next time don't forget to always be learning [Music] [Music] foreign
https://www.youtube.com/watch?v=-PsHyTkgPcA