ACL to hide fields .

Pankaj
Tera Contributor

Hi All,

I have created an ACL (Access Control List) and set the operation = 'read'.

The requirement is to display the 'short_description' field for the 'cab approval' group while hiding it for users outside that group. I attempted to implement this using code, but it doesn't meet the requirement. How can I achieve this?

Image

Pankaj_0-1709098691029.png

 


code

 

 

(function executeRule(current, previous) {
	
    if (current.assignment_group == 'bf2d666f1b457f4042be2fc4bd4bzb97' ) { //cab approval 
        // Check the current user
		
        var currentUser = gs.getUser();
        if (currentUser == '60bb75f21b233510656fc802604bcb00') {
            
             current.setReadAccess('short_description', true); //visible for the user
			
        } else if (currentUser == '038c0d939718d550a2c79534a253af06') {
           
             current.setReadAccess('short_description', false); //hide for the user
        }
    }
})(current, previous);

 

 

 

2 REPLIES 2

Community Alums
Not applicable

Hi @Pankaj  ,

I believe what you can do for checking if the logged in user is part of a that specific group :

if(gs.getUser().isMemberOf('CAB'))

{

answer=true;

}

else

{

answer=false;

}

swathisarang98
Giga Sage
Giga Sage

Hi @Pankaj  ,

 

If Acl doesn't work you can try writing display business rule and onload client script,

Br:

swathisarang98_0-1709103352412.png

 

(function executeRule(current, previous /*null when async*/) {

	g_scratchpad.isMemberOf = gs.getUser().isMemberOf('Database');

})(current, previous);

 

onload:

swathisarang98_1-1709103392597.png

 

function onLoad() {
        if (g_scratchpad.isMemberOf.toString() == 'true')
            g_form.setDisplay('short_description', true);
        else
            g_form.setDisplay('short_description', false);
    }

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang