<< Click to Display Table of Contents >> Revoke case access |
Expression to remove a privileged user
In a Purchase Request Process of the example mentioned in Grant case access we need to exclude the Commercial Vice President as a privileged user, who has no assignment in such cases and who was granted at the beginning of the process. The Commercial Vice President needs to be excluded in the Quotations sub-process using an expression.
As mentioned in the example of the previous article, we store the Commercial Vice President user in a parametric table to easily access and administer the user's ID when call for. This parameter table is associated with the Purchase Request Process.
In step four of the Process Wizard, select the Activity Actions to create an expression On Enter of the sub-process.
The expression removes the Vice President to the list of privileged users. The Vice president's ID is located in the parametric table previously created and assigned to a variable. This variable, in turn, is passed to the function call that revokes the access.
//Obtain VicePresident User
var parameters = new FilterParameters();
parameters.AddParameter("@Code", "CVP");
ViceId=CHelper.getEntityAttrib("Userwithaccess","Usertograntaccess","Code = @Code",parameters);
//Revoke access to VicePresident
CHelper.RevokeCaseAccess(Me.Case.Id,ViceId);
Expression to remove multiple users in the privileged users
In the Purchase Request Process we defined in Grant case access we wish to exclude the Commercial Vice President and the President in the Quotations sub-process using an expression. To do this, we store both users, Commercial Vice President and President, in a parametric table to easily access and administer the user's ID when call for. This parameter table is associated with the Purchase Request Process.
In step four of the Process Wizard, select the Activity Actions to create an expression On Enter of the sub-process.
The following expression adds all users found in the parametric table, that is the President and Vice President. The user ID of each record found in the parametric table is stored in an array. This array is passed to the function call to add the privileged users.
//Obtain list of all users in the 'Users with access' table
UserstoRemove = Me.getXPath("entity-list('Userswithaccess', '')");
//Go through the list
for (Counter=0; UserstoRemove.size()>Counter;Counter++)
{
IdUser=UserstoRemove[Counter].getXPath("Usertograntaccess");
//Validate there are no duplicities
if(!MyArray.Contains(IdUser))
{
//Store users
MyArray.Add(IdUser);
}
//Revoke Access to users
CHelper.RevokeCaseAccessToUsers(Me.Case.Id,MyArray);
}
Last Updated 1/31/2023 4:24:15 PM