Skip to content

Get

Gets a WorkItem instance by its ID.

1
myWorkItem.Get(id: string):WorkItem

Parameters

string id
    The ID of the work item.

Returns

The WorkItem instance.

Remarks

This is useful when you need to refer to older work items while processing the current one. You only need to save the older work item's ID and pass it to the current one. For the previous work item in the workflow, you can use WorkItem.Previous. The ID must be a GUID. A missing work item raises a script error; this method does not return null.

Examples

Refer to an earlier step

1
2
3
4
5
6
// in the pre-work script of the Review step
$Xml.SetValue('ReviewWorkItemId', $WorkItem.Id);

// in a later step
var review = $WorkItem.Get($Xml.Evaluate('ReviewWorkItemId'));
console.log('Review was completed on ' + review.End.toISOString());

See Also