Inactivate All Users in my PDI with Flow Designer and Decision Builder
[Music] thank you hey everyone it's Justin thank you for watching and welcome to my house in this video I want to show you something that I haven't done before I haven't tried before I haven't practiced and um it's part of me cleaning up and securing my PDI I'll link to another video above of where I put on multi-factor authentication in this video what I want to do is I want to inactivate all of these users in my PDI that don't need to be active because I'm not using them and it's my PDI so there's over 978 users in there so I'm going to not script this because that would be too easy to open up script design or script background scripts I'm going to go into flow designer and we're going to see if we can do this with two things a flow and my first stab publicly at a decision table I actually haven't done one of these before yet so let's go ahead and try this we're going to inactivate um all users and obviously there's two users that I'm really concerned about in activating and that would be the admin which is what I'm logged in as and my mid server user which technically like I went and looked it doesn't have a login here I'll show you here my windows Docker user um it doesn't have a login date time which I found interesting because my mid server is working great and notice it was created back in September of 2022 and has been plugging along that's how I do a lot of my stuff but it has no login time but I'm going to do it anyways we're going to set this trigger to a catalog item I can deal with a catalog item later if I want to and I'm going to go ahead and look up all the users in the system so we're just going to do a lookup records and let that load up a table there and I'm just going to type in CIS underscore user and scroll down to users or user let's see scroll too far it's because you guys are watching all right CIS underscore user and um I I can actually do this right here let's just make sure that my user ID is not um you know if I do that I don't need a decision table and I really wanted to use a decision table so I didn't have to keep coming here and adding this flow so let's not put any criteria on there that means if I don't do the filtering here I'm going to have to do the filtering in the decision table as I'm looping through which is fine because it's easy to go up at data decision table it's a bit longer and harder to come in and update a harder you know I'm using that term loosely but let's go ahead add some flow logic here we're going to do for each so I do while no let's just do for each because I'm going to want to look at every single one of these records and uh right behind my head there you can see the user record so I'm just going to drag that over to the user records and we'll do that and now I'm going to do make a decision so let's do make a decision and the decision label is going to be um inactivate oh this will be fun to activate or inactivate is the question all right now let me type that in um now just have a little bit of fun now I don't have a decision table yet for this so let me go ahead and hit my save on my flow in flow designer that's just going to save the work that I've done so far and then I'm going to create a new decision table and this is the part that's really new for me yes I've been in here before have I been here with Utah I don't think I've been in here with Utah my PDI is Utah release at the moment I'm recording this in the middle of while I'm doing all those Utah videos so this is going to be new for me hopefully new for you or if not if you're an expert you can yell at the screen and tell me what I'm doing wrong um we're going to call this decision table uh users not to inactivate not to inactivate I'm going to leave this in global I don't really care about all that and so we'll create and continue um this is something I should be able to recreate if I ever want to do it so I'm not putting this in a scoped application or anything and I really don't need any inputs for this either do I have to specify an info I bet I do so let's I better have to specify a user so let's go ahead and we'll just call this user and this is going to be a reference to uh the assist underscore user table uh you know I think I have seen this before in decision Builder um where when you go to do this select a reference and it fails to fetch we get these internal server errors don't freak out what I've learned just keep on going start typing and type what you need and it's going to keep happening until I get all of that typed in user could be targeting too fast I don't know but I just learned that don't freak out and so if we're gonna pass this a user record there we go that's my okay there's my Mecca this is going to be mandatory we definitely want that and that should be the only input I need and the conditions all right let's add a condition where username it's a username what does I want to do I want to do user ID is probably going to be easiest right user IDs let's do user ID user ID I don't need a description but my input is going to be my user and it's a reference record and then it's going to be condition type reference and actually so this is interesting I want to do I don't want to evaluate the whole record I just want to evaluate that user ID field so let's go ahead and say field there and search for I'm going to forget the same error before user ID okay string default operator is and we'll just say hmm is L value okay so admin is the first one let's double check that actually I have this one highlighted let's just go ahead and copy Windows Docker I want to do that first in my decision table instead of admin and then I'm going to say add a result and the result is going to be true or false and let's see do I have true or false I do there we go and it's going to be false perfect and I'm going to add a new one and this one is going to be my admin user let's just make sure that it is admin it is admin and so we'll go back to our decision Builder and just type in admin there we go and it's going to be false and that's it um if it's anything else uh I need to return true hmm so actually I'm just gonna when I do this decision table if I get back a false I'm going to skip and not do it okay that's going to be the logic here again I'm new to these decision tables so I'm figuring this out as I go with you so we'll go ahead and save this and yeah this should work to do I'm going to do this 978 times that was a lot of users um so there's potential this flow could take a really long time 978 that's okay though okay my decision table is built and so I'm going to close that and that's going to open up all the decision tables I'm back in flow designer now I got to pick my decision table which was inactivate oh it doesn't see the new one yet hopefully like what I call that one uh user is not to activate not inactivate all right execution first decision that matches and where the input is going to be the user record for in the for each Loop which is kind of behind my head so it's right there I'm gonna grab the not the list of user records that we use there but actually the the user record is what I want there so we'll grab that and put that as my input to the decision table all right that's going to return a true or false hmm I wonder if I need to edit that decision table can I edit it from here I can okay I found out something new there flow designer so I can actually edit a decision table right when I'm in the middle of it and what I'm thinking here is do I need a condition where if it's not that if this is false if this is false otherwise it's true so is and this will just say let's see is not empty okay and then we'll just say true and because of the logic on the flow when it reaches that first one Windows Docker one it's going to say false admin false otherwise it's going to inactivate which is true okay that's exactly well so close that all right one little tweak there and uh so my decision is going to be true or false done true or false false is going to be let's just save this if I get another one here because I've just added the true condition to my decision table so I was expecting yeah there we go so if it's true or false if it's false I'm not going to do anything I'm just going to um I'm not gonna do anything there's no reason to do anything I I don't need to activate it but if it's true we're going to inactivate the user so we're going to update the record and I'm going to drag my user record back over there I dragged into the wrong place and we're going to set the active field to which I love this like everywhere else is true false but here it's just going to be an empty box I'm not going to do anything there click done and that should be everything I need so let's save that and let's walk through the logic one more time just to make sure you and I understand I'm going to look up all the user records in the system again that's 978 for each item in there I'm going to call a decision table that decision table is going to return back true or false if it turns false I'm not going to do anything if it returns true I'm going to update the user record and set to inactive that's the idea there let's go ahead and test it we'll pick any rhythm in the system and I'll run this in the background because it's 978 records I don't know how long this is going to take but what should happen is I should start seeing the list of inactive users start growing so it's running we'll click on the flow context to see it there but let's go ahead and go to the user table and let's Group by active and I've got 141 at the moment that are inactive 836 so you can see it's moving through there let's just refresh there okay good it's inactivating everybody which is what I want refresh wouldn't this be cool if I lock myself out of the system yeah it's powering through it it is almost it's got 621 or actually 619 to go because we left two as they're going to stay in there now to 495 this is actually moving a lot faster than I thought it would let's go ahead and refresh this um it's not showing any execution details yet but let's just say refresh again and I've only got 351 still active I don't know what's the difference between this false and not false and why it's grouping them separate that's interesting unless to see what's in that first one oh the user ID is empty okay so that's just going to stay false I didn't do anything in my flow where I was going to activate somebody so that shouldn't be affected unless it says refresh here okay I only got 147 left uh how could this be any more live to do it with you guys I've been activated 830 users in my system I'm thrilled because I really really want to protect my PDI uh let's just hit refresh again see if we're almost there got 147 left it seems so stuck there it's not changing um I can't refresh okay it ran into an error I've got an error uh operation against this user was aborted by business rule ensure active admin remains um okay so that's interesting which one did it showing last 192. so I'm not gonna be able to see so somehow it tried to activate my admin and it shouldn't have tried to inactivate my admin let's just search for a user ID again there he's still active admin admin um my email address is there let's see if my Windows server is there Windows Docker is still active um let's go back to that decision table where we can edit it from photo designer I just want to look at that real quick again and see did I do something did I type in admin wrong because I said is was the qualifier admin or is Windows Docker middle one okay so there's that one it would return false and if it's admin is admin let's make sure there's no hidden spaces in here is admin should not have tried to do this backwards I think I did this backwards false means don't inactivate true means and activate and it should stop it too because two is once it finds a match it should stop it shouldn't go on to row number three in the decision table even if it's admin it should not do that um let's just go back to flow designer first decision that matches I'm not going to run all decisions all right so I have it all set up it should never have tried to inactivate that one let's make sure if it's false it's not going to do anything if it's true it's going to inactivate them so I don't know what it ran across there but you know what we can do let's do this I'm going to change my let's close decision table there I don't need to do anything else there I think I think that's good I'm going to close this history I'm going to modify this lookup user records I am going to set a condition on it I'm going to say look up where the user is active Okay that way I'm not going to get all 978 and have to Loop through them again and then my window or my my amount of stuff I should be able to see which why it's erroring out so we'll just say active is true done save and we'll be able to test this again we'll run it on the same Rhythm we'll run in the background there we go running running there we go and let's go back to uh get rid of my search there on user okay so now it's powering through I've only got 82 left there 24 left and I probably it's going to air out again which it looks like it did test run error and showing the last 71 of 147 and so what we want to do is get to that 71st record there and that is the some where is the error message right there right there's the error message okay this evaluated true let's look at the logs air air occurred against this user is awarded by business rule same errors we got before but I can't tell what user it is answer variable name answer runtime value record not found so I'm stumbling across some user that it thinks is the admin is there another admin user let's look at these 24 that are left I've got admin I've got empties is there another admin user empty could add another decision that if it's empty go ahead and activate it too oh Sam software manager I wonder if that's an admin so somebody in here is an admin and it's not letting me inactivated um which is good I don't want to inactivate an admin user I just need to figure out which one it is so let's go back to my decision table and I want to modify one thing there is my decision table let's open it up I'm going to do if it's in if the user ID is empty you saw those two empty ones there in the list I've got Jim Matthews Amy Chen or both empty I want to inactivate them and then I bet it's the same person uh let's just look at Sam and see his roles does he have a admin role don't see an admin role on them search for administrator nope it's puzzling but my Windows server is still there my admin server okay so let's just go let's go ahead and open that record I'm going to do is empty that's going to return a false as well or true is not empty and then if it gets through all that it's going to be is empty okay we're gonna return a true and hit OK and I'm going to save that that shouldn't activate the empties close that and let's see if we can narrow this down to who this person is when I look this up I'm going to change the sort or the order by and it's been going A to Z let's go ahead and change the Z to A and what that'll do is let us narrow in on who this user is causing the error that I can't see in the logs there so we'll test this again running running running wrote in the background wait for that to finish there good and let's just go ahead and hit refresh 22 don't tell me aired out already did it arrowed out on third one so okay who was the third one if I go Z to A on those trues or sort let's make sure we're sorting by user ID one two three as the windows Docker 01 that's the one it's erroring out on why isn't that matching let's open that user look at the user ID Windows Docker mid 01 let's go to that decision table did I type it in wrong ah here we go I can already tell you man in Utah just working in flow designer and stuff is already faster if you learn to wait on things like that where you click it and nothing happens if you just wait you know be patient it'll eventually work so let's make sure Windows Docker middle one I did is value Windows Docker middle one and it should have returned false and if it returns false it should never get to that it should stay right there so why was it erroring out interesting interesting I could catch the air but then that's you know um it doesn't really tell me why my logic should be working where it should be returning so I got a vlog on the decision table I don't just wear okay here we go oh it's doing it on giraffe lab desetti shirath lagisetti is an administrator whoa what happened there that's a first you're seeing that live I've never seen this before let's see if we can get to our users again all right let's take a look at sharath it's right there last logged in in 2019 rolls let's do star admin it's got a bunch of admin roles and has the admin role interesting so did you guys know that in my PDI sarath lab Society is an admin and that's where I'm airing out so hmm I wonder if it'll let me do that the user cannot be activated it would be fewer than the configure 2 active application administrators all right good to know so I'm going to just set the password here to a bunch of nonsense uh set password or actually this is leave without saving let's try that again a bunch of nonsense the password I'll hit save that way sarath must contain at least one uppercase character or letter all right bunch of nonsense plus one uppercase letter jeez and we'll save all right and then I'm gonna have that user ID in my decision table and then we should be good to go here so I'm going to add another row and let's move that one up to just below can I move this way there we go drag oh please please drag there we go right there and we're going to say is giraffe.ladge study enter and we're going to turn false so all that's good so I've got my mid server my admin and this random person I had no idea existed who's also an admin we're not going to try to inactivate him done with my decision table and we'll go back to our flow and we'll run it one last time and I think we should be done tests same one's fine let's go watch our user table and this should go to three I should have three active users left once this is done there we go I'm down to three should be Windows Docker of one admin and sharath Ledger City and this one should have no errors on it and flow designer has run completed okay so now I've got a working flow now all of you know what to do and your PDI if you want to inactivate everybody I have one last test before we go I want to see if I can still impersonate I didn't know the answer before I did this so let's go ahead and try someone who I end impersonation who am I impersonating uh well in person is another user that's interesting um recent impersonations I can only impersonate three people so let's say able tutor is not found okay so I'm not able to impersonate anybody in my instance who I've been activated which is fine this is my PDI if I do a demo I Can Go activate the person that I need to and then if I do that a bunch of times and now I have a flow where I can go run it real quick and then activate everybody so I'm happy mission accomplished I've secured my PDI both with multi-factor authentication and inactivated all the users who don't need to be active because I'm not using them in my PDI for what I do 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 inactivating hundreds of users in their personal developer instance and until next time don't forget to always be learning [Music] thank you
https://www.youtube.com/watch?v=HWRXqUZbrq0