<< Click to Display Table of Contents >> Clear case access |
The following expressions removes all the users with access to the case, including the creator user. It is strongly recommended to grant access to a user after using this method. Otherwise, the case will be inaccessible. |
Expression to clear the access to a case
In a Purchase Request Process of the example mentioned in Grant case access. Due to security reasons, when the process reaches the Purchase Order Sub-process, we need to revoke the access to this case to all the users and grant access only to the users of the Purchase area, the users in this area may not have any assignment in such cases. Therefore, you need to clear the access to the case and grant access to these users using an expression.
In step four of the Process Wizard, select the Activity Actions to create an expression On Enter of the sub-process.
The expression revokes the access to the case to all the users, including the case creator. Then, it retrieves the users in the Purchases area to grant access to them.
//Clear the access to the current case
var success=CHelper.ClearCaseAccess(Me.Case.Id);
//If the procedure is success, add the Users in Purchase areas. Otherwise, throws an error
if(success)
{
//Get the id of the Purchases area
var parameters = new FilterParameters();
parameters.AddParameter("@areaName", "Purchases");
var AreaId=CHelper.getEntityAttrib("Area","idArea","areaName = @areaName",parameters);
//Get the list of users in the Purchase Area
parameters.AddParameter("@areaId", AreaId);
UserList = Me.getXPath("entity-list('WFUSER','idArea = @areaId')",parameters);
for (Counter=0; UserList.size()>Counter;Counter++)
{
//Get the user id
IdUser=UserList[Counter].getXPath("Id");
//Validate there are no duplicities
if(!MyArray.Contains(IdUser))
{
//Store users
MyArray.Add(IdUser);
}
}
//Grant access to the users list
CHelper.GrantCaseAccessToUsers(Me.Case.Id,MyArray);
}
else
{
// Throw an error if the case access could not be cleared
CHelper.ThrowValidationError("The procedure failed");
}
Expression to clear the access to a list of cases
Complementing the previous example, we also need to revoke the access to the children cases of the current case. You need to clear the access to the case and its children and grant access to these users using an expression.
In step four of the Process Wizard, select the Activity Actions to create an expression On Enter of the sub-process.
The expression revokes the access to the case to all the users, including the case creator. Then, it retrieves the users in the Purchases area to grant access to them.
//Get subprocesses Ids
var CasesArray=CHelper.getSubProcessesId(Me);
//Add the current case Id.
CasesArray.Add(Me.Case.Id);
//Clear the access to the current case
CHelper.ClearCaseAccess(CasesArray);
//Get the id of the Purchases area
var parameters = new FilterParameters();
parameters.AddParameter("@areaName", "Purchases");
var AreaId=CHelper.getEntityAttrib("Area","idArea","areaName = @areaName",parameters);
//Get the list of users in the Purchase Area
parameters.AddParameter("@areaId", AreaId);
UserList = Me.getXPath("entity-list('WFUSER','idArea = @areaId')",parameters);
for (Counter=0; UserList.size()>Counter;Counter++)
{
//Get the user id
IdUser=UserList[Counter].getXPath("Id");
//Validate there are no duplicities
if(!MyArray.Contains(IdUser))
{
//Store users
MyArray.Add(IdUser);
}
}
//Grant access to the users list
CHelper.GrantCaseAccessToUsers(Me.Case.Id,MyArray);
Last Updated 1/31/2023 4:28:33 PM