Adding Operations to Multi-Operation Activities

The Multi-Operation activities that ship with Workflow Studio can be extended to support your own custom operations. In this topic we demonstrate this by adding a new operation called "EditNameAttributes" to the Person Multi-Operation activity we created in the Creating Operation Activities topic.

To add Operations to Multi-Operation Activities

  1. Open the Multi-Operation Operation Activity to which you want to add an Operation. In our example, we using the Operation activity we created in the Creating Operation Activities topic.
  2. With the Multi-Operation Operation activity open in the Activity Designer, right-click on the activity and select Add New Operation from the context menu.




  3. In the Add New Operation window that appears, enter a name for the operation in the Operation Name field and a friendly or display name in the Friendly Name field and then OK to close the window.




  4. Right-click on the activity again and select Edit Operation Executor > Edit EditNameAttributes Executor from the context menu. This allows you to define what occurs when the operation is executed against the Person object.




  5. Type the desired code for the operation executor in the C# Editor that opens. In our example, we have added code to set the FirstName, LastName, and MiddleName attributes to that entered into the workflow form.

    /Set the Person against whom the Operation is being executed to the workflow's target resource
    C.Person person = CurrentWorkflow.TargetResource.Person;
    
    //Set the first name to the approval form's TargetPerson.FirstName property
    person.FirstName = CurrentWorkflow.Form_TargetPerson.FirstName;
    
    //Set the last name to the approval form's TargetPerson.FirstName property
    person.LastName = CurrentWorkflow.Form_TargetPerson.LastName;
    
    //Set the middle name to the approval form's TargetPerson.FirstName property
    person.MiddleName = CurrentWorkflow.Form_TargetPerson.MiddleName;
  6. Next, enter the following code to create an instance of the OperationExecutionSummary to return the results of the operation to the workflow user.

    OperationExecutionSummary opExecutionSummary = (OperationExecutionSummary) Parameters[person.ResourceID.ToString()];
    opExecutionSummary.OperationExecuted = person.Update();
    CurrentWorkflow.OperationExecuted = CurrentWorkflow.OperationExecuted || opExecutionSummary.OperationExecuted;
    Parameters[person.ResourceID.ToString()] = opExecutionSummary;


    The following image shows what the code looks like in the C# Editor.


To have your changes take effect in EmpowerID, be sure to compile and publish any new or edited Operation activities.