Reassign
You can use the Reassign function in Optiva workflows to transfer a workflow task to another user, group, or role. The function enables
- Interactive reassignment- The users select a new assignee.
- Automatic reassignment- Hard coded in the script.
Note: This function is commonly used in
REASSIGN, RETURN, or custom events for task delegation, escalation, and routing.
When to use
You can use this function to:
- Allow users to reassign tasks to other users or groups when the current assignee is unavailable or not the appropriate person.
- Automatically route tasks to specific groups or roles based on business logic or conditions.
When not to use
You cannot use this function on completed tasks.
Note: Reassignment applies only to active workflow tasks.
Syntax
int Reassign(string user, string group, string role);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| user | string | Optional | The new user to be assigned the current task.
Note: You can use empty string "" if not assigning to user.
|
| group | string | Optional | The new group to be assigned the current task.
Note: You can use empty string "" if not assigning to group.
|
| role | string | Optional | The new role to be assigned the current task.
Note: You can use empty string "" if not assigning to group.
|
Note: Specify at least one parameter, or leave all parameters empty for interactive selection.
Working
-
- Interactive Reassignment (All Parameters Empty)
- When all three parameters are empty strings, the function prompts the user to select a new user, group, or role.
-
- Hard-Coded Reassignment (One or More Parameters Specified)
-
When one or more parameters contain values, the task is automatically reassigned to the specified user, group, or role.
Mode Parameters Behvaior Interactive ("", "", "") The user selects new assignee via dialog. User Assignment ("JDOE", "", "") Automatically assign to user JDOE. Group Assignment ("", "FORMULATION", "") Automatically assign to FORMULATION group. Role Assignment ("", "", "QA_MANAGER") Automatically assign to QA_MANAGER role.
Return Value
The application returns a value greater than zero (0) if the operation is successful.
Impact
The application immediately persists reassignment changes to the database.Prerequisites
- The function can reassign only active workflow tasks.
- The specified user, group, or role must exist in the system.
- Specify at least one of user, group, or role, or leave all three parameters empty for interactive selection.
Examples
- Example 1
-
Interactive Reassignment (REASSIGN Event - User Selects New Assignee).
// Script in REASSIGN event // User prompted to select new assignee MessageList("Assign this task to a user, group, or role."); int iReassign = Reassign("", "", ""); return 1;
- Description
- In this example, the script is included in the REASSIGN event. When users click , they are prompted to select a new user, group or role to assign the task to.
- Example 2
-
Interactive Reassignment (RETURN Event - Automatic Reassignment to Group).
// Script in RETURN event // Automatic reassignment to FORMULATION group MessageList("This task is reassigned to the formulas group."); int iReassign = Reassign("", "FORMULATION", ""); return 111;
- Description
- In this example, the script is included in the RETURN event. When a user clicks , the task is reassigned to the FORMULATION group.
- Example 3
-
Reassign to Specific User.
// Reassign task to specific user (e.g., manager) public int ReassignToManager() { AddTraceLog("Reassigning task to manager"); MessageList("Reassigning task to John Doe (Manager)."); int result = Reassign("JDOE", "", ""); if (result == 0) { AddTraceLog("Task reassigned successfully to JDOE"); return 111; // Continue workflow } else { AddTraceLog($"Reassignment failed with code: {result}"); MessageList("Failed to reassign task."); return 1; // Stop workflow } }
- Description
-
This example demonstrates reassigning a workflow task to a specific user (manager JDOE) with validation of the reassignment result and appropriate workflow return codes based on success or failure.