How to set a view on portal if a user has a specific role

Amol Pawar
Tera Guru

Hi All,

 

I have a requirement where I need to show the records in a custom view on the portal if a logged-in user has a particular role.

I have created a custom view and view rule for users who will have that role but that doesn't work.

AmolPawar_1-1694662322314.png

On the portal, I'm fetching the data via a page. When a specific user opens any record he should see in that custom view, but it's not working as expected.

AmolPawar_0-1694662285302.png

Please help me to understand where I'm missing.

 

Thanks in advance,

Amol

2 ACCEPTED SOLUTIONS

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
gs.hasRoleExactly is wrong. hasRoleExactly is not the method of glidesystem api. Please use hasRole method.



Thanks and Regards,

Saurabh Gupta

View solution in original post

Nivedita Patil
Mega Sage
Mega Sage

Hi @Amol Pawar ,

 

Please refer the below code.

 

if(gs.hasRole('role name')){

answer = 'view name' ;

}

 

Mark my answer correct and helpful if helps you.

 

Thanks,

Nivedita Patil.

View solution in original post

4 REPLIES 4

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
gs.hasRoleExactly is wrong. hasRoleExactly is not the method of glidesystem api. Please use hasRole method.



Thanks and Regards,

Saurabh Gupta

Thank you very much @Saurabh Gupta  for your reply.

You are correct! "gs.hasRole()" is correct and working fine.

Nivedita Patil
Mega Sage
Mega Sage

Hi @Amol Pawar ,

 

Please refer the below code.

 

if(gs.hasRole('role name')){

answer = 'view name' ;

}

 

Mark my answer correct and helpful if helps you.

 

Thanks,

Nivedita Patil.

Nivedita Patil
Mega Sage
Mega Sage

Hi @Amol Pawar ,

 

Mark my answer as accepted solution if issue resolved.

 

Thanks,

Nivedita Patil.