Add Activities to Service Request Template using Powershell

Harold_HarrisHarold_Harris Customer IT Monkey ✭
Is there a way to add activities to a Service Request template using PowerShell?

I see ways to add activities to Service Request that have been created but not to a template.

So I would look for Activities that start with a certain name and for each add it to template.

Answers

  • donson_phamdonson_pham Cireson Consultant Adept IT Monkey ✭✭
    Hi Harold, 

    What scenario are you trying to do?  You could possibly just leverage Service Manager out of the box Workflows configuration to do this.  

    I've seen one that depending on a specific criteria in the service request, will slap that specific template for approval.  
  • Harold_HarrisHarold_Harris Customer IT Monkey ✭
    This would mostly be for when creating and testing Service Request.

    At times I need to change multiple PS or other actvities.  

    So instead of going thru the process of deleting the templates and then searching and adding them back in one at a time.  It would save time to be able to just run a script to update all of the templates in the SR template.

    I always name Activity templates that belong to one SR template to start with the same name so that is how I would identify which templates needed to be added.  

    This is just something I thought about after updating activities in a SR template what seemed like about 10 times in 1 hour.  And could not find a way to do it.
  • Nick_FlintNick_Flint Customer Advanced IT Monkey ✭✭✭
    To avoid editing activities on SR Templates (AND to avoid the tedious process of updating PowerShellActivities across multiple templates) I created a PowerShellActivity to run a script that acts as a traffic director. The script grabs the TemplateID of the ServiceRequest once it's created and uses a switch statement to load the script specific to that ServiceRequest. The SR specific script then handles all of the activity creation.

    I find it much easier and faster to edit the powershell script than to mess around in the console editing the activities on the template. 
  • Harold_HarrisHarold_Harris Customer IT Monkey ✭

    Nick, can you share the PowerShell script you use to do this?


    Thanks

Sign In or Register to comment.