Skip to content

SelectedAction

Gets or sets the selected action for the work item.

Type

string

Declaration

1
 string myWorkItem.SelectedAction

Remarks

If no action is selected, this property returns null.

If the WorkItem.State is not in Waiting, Created, or Join, attempting to set this property is prohibited and throws an access denied error.

When setting this property, the task action name is resolved first; its caption is also accepted for backward compatibility. If neither matches, a scripting error is thrown.

Examples

Read the selected action in a post-work script

1
2
3
4
if ($WorkItem.SelectedAction === 'Approve') {
    $Xml.SetValue('Status', 'Approved');
    $Xml.SetValue('ApprovedAt', DateTimeOffset.now);
}

Select an action in script

1
2
3
4
// approve automatically when the amount is under the limit
if ($Xml.EvaluateNumber('Total') < 1000) {
    $WorkItem.SelectedAction = 'Approve';
}