Example - Build A UI Button To Add Departmental Apps To User

Modified on Fri, 31 Mar, 2023 at 6:05 PM

It should be noted that if detail regarding PowerShell Module Commands, Script Variables, etc are required then users should refer to the associated solution article here https://managementstudio.com/a/solutions/articles/14000111736 


TABLE OF CONTENTS


Example

This example will add applications to migration user records if an application is a member of a specific Blueprint.


Step 1: Create some Blueprints for applications by the department

  1.  Go to Administration\Project Admin\Blueprints
  2. Create a new folder below the root called "Apps by Department"
  3. Create some Blueprints underneath "Apps By Department"




Step 2: Add some apps to the new Blueprints

  1. Go to Applications - Main Grid
  2. Select some applications
  3. Right-click and add them to one of the new blueprints you have created.



Note: For the purpose of this exercise add 10-15 apps per Blueprint.



Step 3: Create a PowerShell Object

  • Go to Administration->PS Scripts, Email, Buttons (1)
  • Click on the Project module name (2)


  • Choose Click here to add new item (3) to create a new entry for the script:

  • Set "Script Name" to Link Users to Apps Via Blueprint
  • Set "Category" to Grid Action (Free Type)
  • Select the "User Migrations" from the Module dropdown
  • Set "Run As" to API Account from the dropdown




Step 4: Add The PowerShell Script

Note: While this document will show the PowerShell required to perform this action for detailed information regarding PowerShell please refer to the link at the top of this document.


  1. Click the Edit button on the grid row you configured above
  2. This will open the PowerShell Editor window.
    •  
  3. Paste in the following PowerShell script:
  4. ## Set Button EventArgs1 to be your BP Path i.e. 'Apps By Department\Accounts'
    
    ## Get the Users Selected on the grid when button was pressed
    $userIds = $ScriptArgs.Items
    
    ## Script arguments passed from the button click
    $BP = $ScriptArgs.EventArg1 
    
    ## Get a list of AppIds in the supplied Blueprint
    $appIds = Get-MSApplications -IdsOnly -BlueprintPath $BP
    
    ## Add Blueprint's AppIds to Users
    Add-MSApplicationLinksTo -AppIds $appIds -ToModule "UserMigrations" -ToIds $userIds
    
    ## Add Note to Users 
    $noteToAdd = "Added App Links to User for all Applications in the Blueprint $BP"
    foreach($Id in $UserIds){
        Add-MSUserMigrationNotes -id $Id -NoteText $noteToAdd 
    }
  5. Click 'OK'
  6. Then click 'Save Changes'.



Step 5: Configure a UI Button

  1. Go to Administration\User Migrations\UI Buttons
  2. Scroll to the bottom of the existing button grid and click "Click here to add new item"
  3. Set the button label to "Add Blueprint Apps"
  4. Click the Sub-Button on the row you just created with "Add Blueprint Apps to users" on
  5. Add a button label "Add Account Apps to Users"
  6. Repeat 4 & 5 above until you have two more sub-buttons "Add Production Apps to users" & "Add Sales Apps to users"
  7. Set "Run Script" to "Link Users to Apps Via Blueprint"
  8. You can change button icons if you want, look for new icon names here, and type over the icon name on the grid. 
    • E.g. If we have the icon in ManagementStudio the picture will change. i.e. 
  9. Make sure the new buttons are enabled
  10. Click the extra fields icon in the top right of the screen
  11. Enable the Args1 Checkbox
  12. Add the correct argument for each key




Step 6: Testing The User Module Grid

  1. Load the user module
  2. Right-click a user and select "Add Blueprint Apps" and select one of the sub buttons
  3. Apps will be added to the user and a note added to the user record.






Further Support

If you require further support, please visit ManagementStudio's Service Desk to search the knowledge base or create a new support ticket.