Modify Planned Dates

👍

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

Set Planned Dates depending on the Start Date value

This script updates PlannedStartDate and PlannedEndDate for Tasks (or any other work items) depending on the value of Start Date field. Start Date is used as initial date, then fixed number of days is added.

The webhook assumes it always take 14 days to complete a Task on average. The webhook updates a a field only when its value is blank, dates set earlier are preserved.

https://your-targetprocess-address/api/v1/Tasks?token=[your token]
Update Task
(PlannedStartDate == null or PlannedEndDate == null) and StartDate != null and ProjectName == "My Project"
{
  "Id":{{ID}}
  {% if {{PlannedStartDate}} == null %}, "PlannedStartDate":"{{StartDate | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
  {% endif %}
  {% if {{PlannedEndDate}} == null %}, "PlannedEndDate":"{{StartDate | AddDays: 14 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
  {% endif %}
}

Set PlannedEndDate depending on the Custom Field value

This script updates PlannedEndDate for Requests (or any other work items) depending on the value of "Expected duration" Dropdown Custom Field. PlannedStartDate is used as initial date, then proper number of days is added.

266266

The webhook assumes there are 30 calendar days in a month on average.

https://your-targetprocess-address/api/v1/requests/bulk?token=[your token]
Update Request
ChangedFields.Contains("PlannedStartDate")
[
{
{% if {{ExpectedDuration}} == "1 month" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 30 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% elseif {{ExpectedDuration}} == "2 months" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 60 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% elseif {{ExpectedDuration}} == "3 months" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 90 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% elseif {{ExpectedDuration}} == "4 months" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 120 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% elseif {{ExpectedDuration}} == "5 months" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 150 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% elseif {{ExpectedDuration}} == "6 months" %}
    "Id":{{ID}}, "PlannedEndDate":"{{PlannedStartDate | AddDays: 180 | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
{% endif %}
}
]

Import Planned Dates from Custom Fields

This webhook helps to import and update Planned Start Date, Planned End Date values from CSV files.

By default planned dates cannot be updated from CSV files. They are not available in Import mapping out of box. However Targetprocess supports import of Date Custom Fields from CSV files. Then the webhook is able to copy values from custom fields to built-in fields Planned Start Date, Planned End Date.

If you plan to update dates within some particular type of assignable entity (e.g. User Story, Task, Feature, Epic, Request) in some project, then you have to add two special custom fields to this entity. The fields are used as intermediate storage. Add them in the settings of the process of the project that contains your entities.

Name of the fields are ImportPlannedStartDate, ImportPlannedEndDate. Type of the fields is Date. The fields should not be System.

11361136

Here is how the webhook should be configured:

https://your-targetprocess-address/api/v1/Assignables?token=[your token]
Create, Update // User Story, Task, Feature, Epic, Request
ProjectName == "My Project" and (ImportPlannedStartDate != Previous.ImportPlannedStartDate or ImportPlannedEndDate != Previous.ImportPlannedEndDate)
{
  "Id":{{ID}}
  {% if {{ImportPlannedStartDate}} != null %}
    ,"PlannedStartDate":"{{ImportPlannedStartDate | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
  {% endif %}
  {% if {{ImportPlannedEndDate}} != null %}
    ,"PlannedEndDate":"{{ImportPlannedEndDate | Date:"yyyy-MM-dd HH:mm:ss zzz"}}"
  {% endif %}
}

Link Planned Dates of several items

In this use case we connect items in a specific order (e.g. Task A has to be done after Task B).
If Planned Date of one item is changed, all the subsequent items will be shifted accordingly.

Note that the 'Next Item' is specified manually. You manually input its numeric ID to the Custom Field of the 'Previous Item'.

📘

Inbound and Outbound Relations do not participate in the automation. Next Item ID is not the ID of the 'Outbound' Assignable entity.

🚧

Sometimes IDs are changing!

If the ID of linked item is changed for some reason (say, the User Story is converted to Bug / Feature or vice versa) then you have to not forget manually update ID in 'Next Item' field as well.

This rule requires initial configuration. Before make it working you as Administrator should add special Custom Field of type Number with name "Next Item ID" for User Story, Task, Bug entities.

736736

Here is how the webhook itself is configured:

https://your-targetprocess-address/api/commands/v1/execute?token=[your token]
Update User Story, Task, Bug
NextItemID != null and ChangedFields.Contains("PlannedEndDate")
{
Id: {{NextItemID}},
Name: "MoveAssignablePlannedDates",
Days: {{PlannedEndDate|DiffDays: Previous.PlannedEndDate}}
}

How to test the webhook:

  1. Create User Story US1. Say, its ID is 12345
  2. Create User Story US2. Say, its ID is 12346
  3. Fill in planned end date for US1. Set it to 1 Jan 2018.
  4. Fill in planned end date for US2. Set it to 1 Feb 2018.
  5. Fill in 'Next Item ID' field for US1. Put there 12346. Now the system knows that two stories are linked.
  6. Update planned end date for US1. Set it to 8 Jan 2018.
  7. The system automatically updates planned end date for US2. It becomes set to 8 Feb 2018.

🚧

Planned Start Date of first story does not shift whole queue

The webhook does not reschedules next items when you change only planned start date of the first item in the chain, keeping its planned end date unchanged.