VA Topic should be visible based on logged in user role

divya216
Tera Contributor

Hello 

I want to hide the VA topic if user don't have an 'snc_internal' role.

 

I have tried below approach

(function execute() {
 var udc = new GlideRecord('sys_user_role');
udc.addQuery('sys_id','7fcaa702933002009c8579b4f47ffbde');
udc.query();
if(udc.next()){
return true;
} 
else { 
return false;
} 
})()

But this is not working as expected.

 

Thanks!

10 REPLIES 10

Hi @divya216 ,

Can you try this code in script  of Context field in Additional properties:

var role = vaContext.role == 'snc_internal' ? true : false;

return role;

 

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023

Badal Khojare
Mega Sage
Mega Sage

Hi @divya216 ,

Please let me know if this still does not work for you or there is some other issue. 

 

 

 

 

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023

Hi,

No its not working yet.

Hi @divya216 ,

Can you share screenshot of your script that you pasted in your Context script. It should look like :

 

(function execute() {

var role = vaContext.role == 'snc_internal' ? true : false;

return role;

return true;

})()

This script you have to paste by going to Topic > Properties > Advanced properties > Context > Select Script option > Click on Edit script and paste this script

 

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023

Hii,

Topic is not visible to the snc internal role as well.
Please find the attached screenshot below:

divya216_0-1697782522179.png