## Documentation

Subscription

• Specific Roles

• Multiple Roles of a Role type (Organization, Site, Asset Library, Account, or Regular Role types)

• The Asset Creator

• Resource Actions

• Specific Users

Additionally, you can write a script to define the assignment (see Scripted Assignments).

## Resource Action Assignments¶

You can assign a workflow task to a Resource Action. Resource actions are operations performed by Users on an application or entity. For example, a User might have permission to update Message Boards Messages. This is called an UPDATE resource action, because the User can update the resource. If your workflow definition specifies the UPDATE action in an assignment, anyone with permission to update the asset type being processed in the workflow is assigned to the task. You can configure multiple assignments for a task.

Here’s what the assignment looks like in the Source (Workflow XML) view:

<assignments>
<resource-actions>
<resource-action>UPDATE</resource-action>
</resource-actions>
</assignments>


You can assign the workflow to the appropriate workflow enabled asset.

Now when the workflow proceeds to the task with the resource action assignment, Users with UPDATE permission on the resource (for example, Message Boards Messages) are notified of the task and can assign it to themselves (if the notification is set to Task Assignees). Specifically, Users see the tasks in their My Workflow Tasks application under the tab Assigned to My Roles.

Note

The My Workflow Tasks application is accessible from a User’s personal menu:

Use all upper case letters for resource action names. To enter more than one, use a comma-separated list. Here are some common resource actions:

• UPDATE

• DELETE

• VIEW

• PERMISSIONS

• SUBSCRIBE

You can determine the probable resource action name from the permissions screen for that resource. For example, in Message Boards, one of the permissions displayed on that screen is Add Discussion. Convert that to all uppercase and replace the space with an underscore, and you have the action name.

## Scripted Assignments¶

You can also use a script to manage the assignment. Here’s the script for the Review task assignment in the Scripted Single Approver workflow definition (single-approver-definition-scripted-assignment.xml):

import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.Role;
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
import com.liferay.portal.kernel.service.RoleLocalServiceUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;

long companyId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));

long groupId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));

Group group = GroupLocalServiceUtil.getGroup(groupId);

roles = new ArrayList<Role>();

if (group.isOrganization()) {
Role role = RoleLocalServiceUtil.getRole(companyId, "Organization Content Reviewer");

}
else {
Role role = RoleLocalServiceUtil.getRole(companyId, "Site Content Reviewer");


Note the roles = new ArrayList<Role>(); line above. In a scripted assignment, the roles variable is where you specify any Roles the task is assigned to. For example, when roles.add(adminRole); is called, the Administrator Role is added to the assignment.