Modify States of work items

These webhooks change states of work items in Targetprocess.

Prerequisites: IDs of Entity States

The templates in these examples contain IDs of the entity states as parameters. In the template pass numeric ID of required state obtained from workflow settings for Requests in selected process.

📘

How to get numeric IDs of entity states

Execute a GET call to Targetprocess API to retrieve IDs from your workflow settings.

Option 1: Get list of next available states for a given entity.

For example, for the entity #1234:

GET /api/v1/Assignables/1234?include=[EntityState[NextStates[Id,Name]]]

Option 2: Get list of all states related to particular process and entity type.

For example, for 'Requests' in 'Scrum' process:

GET /api/v1/EntityStates?where=(Process.Name eq 'Scrum') and (EntityType.Name eq 'Request')&include=[Id,Name]&orderby=NumericPriority

🚧

States in different Processes and for different Entities have different IDs

Basic webhooks are configured for single process. If the webhook is intended to work with entities in multiple processes, or with entities of multiple types, you must customize template with special conditions that include process-specific and entity-specific IDs of states. See example in the bottom of this page.

Reopen a Request when new Comment is submitted to it

👍

Please consider using the following Automation Rule instead of this webhook.

Sometimes users find closed tickets (Requests) in your Service Desk and post comments to them. The webhook helps to reopen the tickets once it happens. As a result the request automatically appears in the incoming queue and your Support Agents are able to react to the recent comment timely.

The webhook is automatically executed when a new Comment is submitted to a Request. The profile provided below helps to set up the webhook for specific projects only and exclude some users and types of requests from the processing flow.

https://your-targetprocess-address/api/v1/Requests?token=[your token]
Update Request
//for Projects with specific IDs
//do not apply to Requests that are in 'New' state already
//do not reopen when comment is submitted by users with specific IDs
//do not reopen requests of type 'Idea'

ProjectID in [79164, 70716, 49402, 73414, 92364, 2, 49105, 141000] and LastCommentDate != Previous.LastCommentDate and EntityStateName != 'New' and not(LastCommentUserID in [15388, 29002, 33884, 19619, 57508, 64777, 73962, 75012, 76439]) and RequestTypeName != 'Idea'
{
  Id:{{ID}},
  EntityState:{Id:873}
}

Template for multiple Processes

If a webhook is intended to work with states of entities from multiple processes, you must customize template with special conditions and process-specific IDs.

{% if {{ProjectID}} == 70716 or {{ProjectID}} == 49402 %}
  {ID:{{ID}},EntityState:{Id:873}}
{% else %}
  {ID:{{ID}},EntityState:{Id:19}}
{% endif %}