Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# ITaskList.SetAccessLevel Method

Set task list access level for a given role type.

void SetAccessLevel(
RoleTypes roleType,
AccessLevels accessLevel
);

#### Parameters

roleType
  The role type for which access level will be set; cannot be `null`.
accessLevel
  The access level; cannot be `null`.

#### Remarks

The task list must have its default security disabled prior to this call using `}DefaultSecurity=false`. Any security change on the task list will be automatically applied to all tasks in this task list after `Store` is called. Trying to modify the access level for a Leader role type will throw `CollaborationException` upon `Store`. Below sample code shows how to set the access level on a discussion.

    //verify if the current user has the permission to edit security for the discussion
    bool hasPermission = discussion.IsActionAllowed(DiscussionPermissions.EditSecurity);

    //after making sure the current user has permission to edit security, modify the access level
    if (hasPermission)

    {
    //first disable using project default security
    discussion.DefaultSecurity = false;

    //then change discussion to have the READ access level for member role type
    discussion.SetAccessLevel(RoleTypes.Member, AccessLevels.Read);

    //need to store the discussion to persist the access level change
    discussion.Store();
    }

#### Exceptions

Exception Type | Condition
--- | ---
InvalidOperationException | Project default security is used, call `setDefaultSecurity(false)` prior to modify object access level.

#### See Also

ITaskList Interface | Plumtree.Remote.PRC.Collaboration.Tasklist Namespace