Create Remedy Work Orders with PowerShell

In previous posts, I have shown you how to query for data in Remedy using PowerShell and ARAPI.NET. Creating or updating information in Remedy is not much different.

  1. Log into the AR Server
  2. Build a list of Field IDs and values that you want the Work Order to contain
  3. Use the CreateEntry method to create a new Work Order
  4. Create a Qualifier string used to query for the newly created Work Order
  5. Build a list of Field IDs that you want to retrieve from Remedy
  6. Query a Remedy form (passing in the qualifier and field list)
  7. Process the results
  8. Log off the AR Server

The following script is a simple example to create a single Work Order in Remedy. It could easily be adapted to read from a CSV file or other data source to create multiple work orders. In fact, I wrote a tool in C# that is designed to create multiple Work Orders from CSV data. We use it to create the same Work Order task for multiple individual store locations.

The hardest part about creating items in Remedy is knowing which form to use and which data fields are required. It is not always obvious which fields are required. You may have to use Developer Studio to inspect the workflow and filter logic to figure all of that out. Also, fields like Product Categories, Operational Categories, Support Queues, etc. will have values specific to your environment.

param ($appServer = "",
       $svcAccount = "remedyuserid",
       $svcPassword = "remedypassword",
       $remAuthDomain = "",
       $arSrvrPort = 51100,
       $formName = "WOI:WorkOrderInterface_Create")

add-type -path 'C:\Program Files (x86)\BMC Software\ARAPI80.NET\BMC.ARSystem.dll'

$arserver = New-Object -type BMC.ARSystem.Server
$arserver.Login($appServer, $svcAccount, $svcPassword, $remAuthDomain, $arSrvrPort)

$fieldIDs = @{     2="";           #Submitter
                   3="";           #Create Date
          1000000182="";           #Work Order ID
          ### Store identity
          1000000082="Contoso";    #Company
           301593100="s01174";     #RequesterLoginID
          1000000001="HQ";         #Location
          1000000018="Bloggs";     #Last Name
          1000000019="Joe";        #First Name
          ### WO Actions
          1000000000="Summary: short version of description";
          1000000151="Details: long version of description";
          ### Op Cat Tiers 1,2,3
          1000000064="Add hardware";
          1000000065="Wiring Closet";
          ### Prod Cat Tiers 1,2,3
          1000001270="Hardware Lifecycle";
          1000001271="Hardware replacement";
          1000001272="Internal Project";
          ### Product
          1000002268="Wireless Access";
          ### Manager Support Hierarchy
          1000000014="Infrastructure";  #Manager Support Org
          1000000015="Network";         #Manager Support Group
          1000000251="Contoso";         #Manager Company
          ### Support Hierarchy
          1000003227="Infrastructure";  #Support Org
          1000003228="Network";         #Support Group
          1000003229="Contoso";         #Company
          ### Customer Info Returned
          1000003296=""; #Customer Person ID
          1000003297=""; #Customer First Name
          1000003298=""; #Customer Last Name
          1000003299=""; #Customer Company
          1000003302=""; #Customer Email
          1000003306=""; #Customer Phone Number

   #Build the list of field values to be used in the Create request - skip blank values
   [BMC.ARSystem.FieldValueList] $woValueList = New-Object -type BMC.ARSystem.FieldValueList
   $fieldIDs.keys | ForEach-Object {
      if ($fieldIDs[$_] -ne "") {
   #Create then new WO with listed values
   $entryID = $arserver.CreateEntry($formName, $woValueList);

   #Build a new field list containing ALL the fields you want returned
   [BMC.ARSystem.EntryListFieldList] $woEntryFieldList = New-Object -type BMC.ARSystem.EntryListFieldList
   $fieldIDs.Keys | ForEach-Object { $woEntryFieldList.AddField($_); }

   #Query for the newly created WO by its EntryID
   $strSQL = "'1' = {0}" -f $entryID
   [BMC.ARSystem.EntryFieldValueList] $woEntryValueList = New-Object -type BMC.ARSystem.EntryFieldValueList
   $woEntryValueList = $arserver.GetListEntryWithFields($formName, $strSQL, $woEntryFieldList, 0, 50);

   #Output the results
   $fieldIDs.Keys | ForEach-Object { "[{0:0000000000}] {1}" -f $_,$woEntryValueList.fieldvalues[$_] }

Updating values on an existing item in Remedy is not much different. The process is mostly the same but you are using the SetEntry method instead of the CreateEntry method. I will try to share an update example in an upcoming post.

I am an experienced IT technologist specializing in optimizing user experiences, providing best-in-class support and developing creative solutions. I script therefore I am. I build tools to improve troubleshooting and gather supporting data.

Tagged with: ,
Posted in ARAPI, PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

sean on it
Follow Sean on IT on
Blog Stats
  • 65,942 hits
Mike F Robbins

Scripting | Automation | Efficiency

%d bloggers like this: