Assign an ACL role to a user in the Assigned to variable on Catalog items

humblecommitted
Kilo Guru

Hello Community,

I was wondering if it was possible to grant a user's account rights/roles when they have been inputted into the Assigned to field of Requests.  

The situation is, I have locked down certain variables on the request form to not allow any user to make changes to them.

I would like to create a condition where the users name inputted into the Assigned to field will be also granted the role to edit the locked down variable.

In this instance we have secured the Work start/end times.   We would like the person in the Assigned to field to be able to make changes to the work start/end times.

1.1.jpg

Any help to point me in the right direction would be greatly appreciated.  

Sincerely,

Orlando Galindo

1 ACCEPTED SOLUTION

Hello Community,



I was able to answer this in another forum.



Here is the solution:


How to query a certain user's role



  1. answer = ifScript();      
  2.           function ifScript() {      
  3.                 //answer = 'false';    
  4.   var userID = gs.getUserID();      
  5.            
  6.   gs.log("work start check for " + userID + " assigned_to " + current.assigned_to);      
  7.     if (userID == current.assigned_to) {      
  8.     return 'true'; }      
  9.            
  10.     // query to see if userID has role change management, if so return true    
  11.      
  12.   var cm_role = new GlideRecord('sys_user_role');  
  13.   cm_role.addQuery('name', "change_management");  
  14.   cm_role.query();  
  15.   while (cm_role.next()) {  
  16.  
  17.  
  18.   var roles = new GlideRecord('sys_user_has_role');            
  19.   roles.addQuery('user', userID);                
  20.   roles.addQuery('role', cm_role.sys_id);            
  21.   roles.query();            
  22.   while (roles.next()){  
  23.   gs.log("work start role check for " + userID + " has role " + cm_role.name);  
  24.   return true;    
  25.   }  
  26.   }  
  27.   gs.log("end of work start role check for " + userID + ", no writing allowed" );  
  28.       return false;          
  29. }  

View solution in original post

5 REPLIES 5

Karan Sharma3
Tera Expert

I had tried ACL's on variable pool but they didn't worked for me.



What I did was used a client script to check if the logged in user is assigned to, then make the variables.<variable_name> readonly false.


Hello Karan,



Would it be OK to request your client script code so that I may review it?



Thank you


On Load script:



var userID = g_user.userID;


if (userID == g_form.getValue('assigned_to'))


{


  g_from.setReadOnly('variable.<variable name>', false);


}


Hello Karan,



I tried that code, and I see there may be some type of configuration to fine tune it to my particular scenario.



Would you think there would be a way to snip in a string of code that could be applied the the Access Control for the particular variable like in the screen shot below?



1.1.jpg



any help would greatly be appreciated.