Introduction
You can use variables in several Service Automation features, including:
- Tasks using templated PowerShell scripts
- Tasks using inline PowerShell scripts
- Product actions using PowerShell scripts
- Product actions using tasks from the Task Catalog
- Delegated form PowerShell actions
- Task data sources
- PowerShell data sources
How to use Service Automation variables
In PowerShell scripts with a Variables tab
In features where the PowerShell script has a Variables tab, you cannot use these variables directly in your PowerShell script. You must first include the variables in the scope of the script.
To do so:
- Enter a variable Name.
- Enter a variable Value using double curly brace syntax. An autocomplete popup appears when you type
{{
, to indicate the available variables. To access global variables, use{{variable.}}
. - Click the plus (+) button to save the variable(s).
- Click the Close button.
- Click the Save button.
- You can now access the variable in your PowerShell script using the local Name that you defined.
In PowerShell scripts without a Variables tab
In features where the PowerShell script does not have a Variables tab, you can use these variables directly in your PowerShell script. To access global variables, use the variable name directly.
For example, in a PowerShell data source:
In Product actions using tasks from the Task Catalog
Use double curly brace syntax to access variables in production action fields. An autocomplete popup appears when you type {{
, to indicate the available variables. To access global variables, use {{variable.}}
.
Service Automation variable reference
dateTime
- dateTime
- companyTimeZoneNow
- utcNow
Available in:
- ❌ Tasks using templated PowerShell scripts
- ✔️ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
2022-05-24T13:44:09.0746666
manager
- manager
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
{ "FullName": "John Doe", "ManagedByUserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "FirstName": "John", "LastName": "Doe", "UserName": "jdoe", "UserGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "ContactEmail": "jdoe@tools4ever.com", "IsEnabled": "True", "Source": "Local", "ImmutableId": null, "UserAttributes": { "PHONENUMBER": "5555555555", "LANGUAGE": "EN", "FIRSTNAME": "John", "LASTNAME": "Doe", "CONTACTEMAIL": "jdoe@tools4ever.com", "FULLNAME": "John Doe" }, "Attributes": { "PHONENUMBER": "5555555555", "LANGUAGE": "EN", "FIRSTNAME": "John", "LASTNAME": "Doe", "CONTACTEMAIL": "jdoe@tools4ever.com", "FULLNAME": "John Doe" } }
portal
- portal
- baseUrl
- companyIcon
Available in:
- ❌ Tasks using templated PowerShell scripts
- ✔️ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
{ "BaseUrl": "https://t4e-seattle.helloid.com", "CompanyIcon": "https://t4e-seattle.helloid.com/appearance/companyicon" }
product
- product
- selfServiceProductGUID
- name
- description
- icon
- options
- sourceIdentifier
- multipleRequestOption
- ownershipMaxDuration
- useFaIcon
- faIcon
- code
- agentPoolGUID
- maxCount
- riskFactor
- price
- approvalWorkflowGUID
- agentPool
- approvalWorkflow
- managedByUser
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
{ "ManagedByGroupGUID": "0af6fee0-16a6-4b92-9027-6dc598c92c56", "ManagedByGroup": { "Name": "Admins", "GroupGUID": "0af6fee0-16a6-4b92-9027-6dc598c92c56" }, "Options": 128, "OwnershipMaxDuration": 864000, "SelfServiceProductGUID": "a1020197-e703-4338-a32c-c1d175e86ee1", "Name": "Adobe Illustrator", "Description": null, "Icon": "469261615F2D7C1E7901F3DFE97B6CBC", "SourceIdentifier": null, "MultipleRequestOption": 3, "UseFaIcon": false, "FaIcon": null, "Code": "20200617JUZUVCYHQF", "MaxCount": null, "RiskFactor": 1, "Price": null }
request
- request
- formJson
- formResultGUID
- selfServiceRequestGUID
- selfServiceProductGUID
- requestedByUserGUID
- state
- options
- requestedTime
- comment
- lastReminderTime
- productSKU
- toDate
- serviceRequestedTime
- requestedForUserGUID
- approveCompletedAt
- requestedBy
- requestedFor
- selfServiceProduct
- approvalHistory
- tojsonstring
- count
- form
- [form object]
- [datasource objects]
- [form object]
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
{ "FormJson": null, "FormResultGUID": null, "ApprovalHistory": [], "Form": null, "Comment": null, "State": 1, "Options": 0, "SelfServiceRequestGUID": "ac70a837-e570-4c8b-b08c-ddce7de07de6", "SelfServiceProductGUID": "a1020197-e703-4338-a32c-c1d175e86ee1", "ToDate": null, "RequestedTime": "2022-06-07T17:48:44.217", "SelfServiceProduct": { "ManagedByGroupGUID": "0af6fee0-16a6-4b92-9027-6dc598c92c56", "ManagedByGroup": { "Name": "Admins", "GroupGUID": "0af6fee0-16a6-4b92-9027-6dc598c92c56" }, "Options": 128, "OwnershipMaxDuration": 864000, "SelfServiceProductGUID": "a1020197-e703-4338-a32c-c1d175e86ee1", "Name": "Adobe Illustrator", "Description": null, "Icon": "469261615F2D7C1E7901F3DFE97B6CBC", "SourceIdentifier": null, "MultipleRequestOption": 3, "UseFaIcon": false, "FaIcon": null, "Code": "20200617JUZUVCYHQF", "MaxCount": null, "RiskFactor": 1, "Price": null }, "RequestedBy": { "FullName": "Administrator", "ManagedByUserGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "FirstName": "Administrator", "LastName": null, "UserName": "Administrator", "UserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "ContactEmail": "admin@advtoolware.com", "IsEnabled": "True", "Source": "Local", "ImmutableId": null, "UserAttributes": { "PHONENUMBER": "", "LANGUAGE": "EN", "FIRSTNAME": "Administrator", "LASTNAME": null, "CONTACTEMAIL": "admin@advtoolware.com", "FULLNAME": "Administrator" }, "Attributes": { "PHONENUMBER": "", "LANGUAGE": "EN", "FIRSTNAME": "Administrator", "LASTNAME": null, "CONTACTEMAIL": "admin@advtoolware.com", "FULLNAME": "Administrator" } }, "RequestedByUserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "HandledBy": null, "HandledByUserGUID": null, "RequestedFor": { "FullName": "John Doe", "ManagedByUserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "FirstName": "John", "LastName": "Doe", "UserName": "jdoe", "UserGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "ContactEmail": "jdoe@tools4ever.com", "IsEnabled": "True", "Source": "Local", "ImmutableId": null, "UserAttributes": { "PHONENUMBER": "5555555555", "LANGUAGE": "EN", "FIRSTNAME": "John", "LASTNAME": "Doe", "CONTACTEMAIL": "jdoe@tools4ever.com", "FULLNAME": "John Doe" }, "Attributes": { "PHONENUMBER": "5555555555", "LANGUAGE": "EN", "FIRSTNAME": "John", "LASTNAME": "Doe", "CONTACTEMAIL": "jdoe@tools4ever.com", "FULLNAME": "John Doe" } }, "RequestedForUserGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "ReturnedBy": null, "ReturnedByUserGUID": null, "ReturnTime": null, "ReturnComment": null, "ServiceRequestedTime": null, "LastReminderTime": null, "ApproveCompletedAt": null, "ProductSKU": "20200617JUZUVCYHQF" }
requester
- requester
The requester
is the user object of the currently logged in user, who is requesting the product or submitting the delegated form. For product requests, the requester is often, but not always, the same user that the product is being requested for.
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ✔️ Delegated form PowerShell actions
- ❌ Task data sources
- ✔️ PowerShell data sources
Example:
{ "FullName": "Administrator", "ManagedByUserGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "FirstName": "Administrator", "LastName": null, "UserName": "Administrator", "UserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "ContactEmail": "admin@advtoolware.com", "IsEnabled": "True", "Source": "Local", "ImmutableId": null, "UserAttributes": { "PHONENUMBER": "", "LANGUAGE": "EN", "FIRSTNAME": "Administrator", "LASTNAME": null, "CONTACTEMAIL": "admin@advtoolware.com", "FULLNAME": "Administrator" }, "Attributes": { "PHONENUMBER": "", "LANGUAGE": "EN", "FIRSTNAME": "Administrator", "LASTNAME": null, "CONTACTEMAIL": "admin@advtoolware.com", "FULLNAME": "Administrator" } }
requestedFor
- requestedFor
The user object of the user who the product was requested for.
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ❌ Product actions using PowerShell scripts
- ❌ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ✔️ PowerShell data sources
Example:
{ "userGUID": "c351637c-7c80-484e-bf97-013ebaa41bc4", "userName": "jdoe", "firstName": "John", "lastName": "Doe", "fullName": "John Doe", "contactEmail": "jdoe@tools4ever.com", "userAttributes": { "phonenumber": "5555555555", "language": "EN", "department": "Marketing", "privateEmail": "" }, "createdOn": "2021-11-30T22:54:47.503", "managedByUserGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "isEnabled": "True" }
resourceOwnerGroup
- resourceOwnerGroup
- name
- groupID
Available in:
- ❌ Tasks using templated PowerShell scripts
- ❌ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ❌ Delegated form PowerShell actions
- ❌ Task data sources
- ❌ PowerShell data sources
Example:
{ "Name": "Admins", "GroupGUID": "0af6fee0-16a6-4b92-9027-6dc598c92c56" }
Global variables
All global system and user-defined global variables in the Variable Library.
Available in:
- ✔️ Standalone PowerShell scripts used in task data sources and as templates
- ✔️ Tasks using inline PowerShell scripts
- ✔️ Product actions using PowerShell scripts
- ✔️ Product actions using tasks from the Task Catalog
- ✔️ Delegated form PowerShell actions
- ✔️ Task data sources
- ✔️ PowerShell data sources
User object
- fullName
- firstName
- lastName
- userName
- userGUID
- contactEmail
- isEnabled
- source
- immutableId
- userAttributes
- [user attributes that have been mapped into HelloID]
- tojsonstring
{ "userGUID": "bc61948e-2a84-41fa-9b2a-4d5e94e319db", "userName": "Administrator", "firstName": "Administrator", "fullName": "Administrator", "contactEmail": "admin@advtoolware.com", "userAttributes": { "phonenumber": "", "language": "EN" }, "createdOn": "2021-10-26T19:05:37.833", "isEnabled": "True" }
Form object
{ "dropDown": "Option 2", "dateTime": "2022-06-07T18:40:20.949Z", "multiCheckbox": [ { "label": "Option 1", "value": true, "mustBeTrue": false }, { "label": "Option 2", "value": false, "mustBeTrue": false }, { "label": "Option 3", "value": true, "mustBeTrue": false } ], "textDatasource": "Text value returned from PowerShell datasource", "dropDown1": { "a": "A dropdown value, returned from a second PowerShell datasource", "b": "Another dropdown value, returned from a second PowerShell datasource" } }