TokenTask
require(["esri/tasks/workflow/TokenTask"], function(TokenTask) { /* code goes here */ });
esri/tasks/workflow/TokenTask
Helps you parse Workflow Manager tokens to the actual value of tokens in the job.
Tokens are placeholder text for dynamic properties that will be replaced at run time. For example, if you want to define an email message that will be sent automatically at certain times with job information and you want to add the id of the job to the message, you can add a placeholder token that will be replaced at run time with the value of job id.
The following types of embedded tokens are supported:
- Job Properties ([JOB:])
- Extended Properties ([JOBEX:])
- System ([SYS:])
- Functions
- Spatial Notification ([SN:])
- Environment Variable Parser ([ENV:])
For example:
- Parsing the token string "[JOB:ID] [JOB:ASSIGNED_TO] [JOB:START_DATE]" would return a result such as "401 demo 6/14/2017", where the job id is 401, it is assigned to demo user and the start date is 6/14/2017.
- Similarly, parsing the function token string "[EMAILOF(jbloggs)]" would return a result such as jbloggs@email.com, which is the value for user jbloggs email address.
Constructors
- new TokenTask(properties)
- Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | The name of the class. more details | more details | Accessor | |
Object | The options to be used for data requests. more details | more details | Task | |
String | URL to the ArcGIS Workflow Manager REST service. more details | more details | TokenTask |
Property Details
- Since: ArcGIS API for JavaScript 4.7
The name of the class. The declared class name is formatted as
esri.folder.className
.
The options to be used for data requests. These options can also be controlled through the
requestOptions
method parameter.
- urlString
URL to the ArcGIS Workflow Manager REST service.
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
Promise<String> | Parses a string with embedded tokens using user and job information. more details | more details | TokenTask |
Method Details
Parses a string with embedded tokens using user and job information. The string is returned with embedded tokens replaced by their actual values.
Parameters:params ObjectSee the object specifications in table below for the structure of the
params
object.Specification:jobId intA unique id for the job.
stringToParse StringThe string representing the tokens to be parsed.
user StringThe username of the user requesting token parsing.
requestOptions ObjectoptionalAdditional options to be used for the data request (will override requestOptions defined during construction).
Returns:Type Description Promise<String> When resolved, returns the parsed string with the value of tokens. Example:var params = { jobId: 1501, stringToParse: "[JOB:ID] [JOB:ASSIGNED_TO] [JOB:START_DATE]", user: "cjones" }; tokenTask.parseTokens(params).then(function(parsedString){ // return a result such as "1501 Technicians 6/14/2017" console.log("parsedString = " + parsedString); });