require(["esri/tasks/workflow/TokenTask"], function(TokenTask) { /* code goes here */ });
Class: esri/tasks/workflow/TokenTask
Inheritance: TokenTask Task Accessor
Since: ArcGIS API for JavaScript 4.3

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 Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
Object

The options to be used for data requests.

more details
more detailsTask
String

URL to the ArcGIS Workflow Manager REST service.

more details
more detailsTokenTask

Property Details

declaredClassStringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

requestOptionsObject inherited

The options to be used for data requests. These options can also be controlled through the requestOptions method parameter.

URL to the ArcGIS Workflow Manager REST service.

Method Overview

NameReturn TypeSummaryClass
Promise<String>

Parses a string with embedded tokens using user and job information.

more details
more detailsTokenTask

Method Details

parseTokens(params, requestOptions){Promise<String>}

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 Object

See the object specifications in table below for the structure of the params object.

Specification:
jobId int

A unique id for the job.

stringToParse String

The string representing the tokens to be parsed.

user String

The username of the user requesting token parsing.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
TypeDescription
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);
});

API Reference search results

NameTypeModule

There were no match results from your search criteria.