User need to see the record in portal

suuriyas
Tera Contributor

HI Community,

 

I have a requirement, there is a table called "cases" in that there is field called external provider (similar to watchlist) when the user is added to that external provider field then the record needs to be visible to the added user (in external provider)in portal.

 

For that i have created one read acl but it is not working.

suuriyas_0-1753189619132.pngsuuriyas_1-1753189669351.png

 

3 REPLIES 3

anshul_goyal
Kilo Sage

Hello @suuriyas,

Try below script in ACL

(function() {
     answer = false;
    // external_provider is a glide list (comma-separated sys_ids)
    var users = current.external_provider.toString().split(',');

    if (users.indexOf(gs.getUserID()) !== -1) {
        answer = true;
    }
})();


Please mark my response as Accepted and Helpful for future references.

Thanks

Harish LS
Giga Guru

Hi Suuriyas,

Try the below code in your read acl.

 

HarishLS_0-1753191065999.png

 

ChiranjeeviR
Kilo Sage

Hi @suuriyas,

 

based on Snip, i could see there is some small i would recommend

1. ACL script execution order

 ensure record-level Read ACL is set properly

ACLs evalaute properly

  a.table.None

  b.table.field

so, if you only created a field level ACL make sure the Table level also allows access

 

2. ACLScript

(function() {
var userId= gs.getUserId();//current logged in user
var fieldValue = current.external_provider.toString();//conver to comma separated string

if(fieldValue.index(userId) !== -1{
answer =true;
}
else
{
answer=false;
}
})();

 

3. save and test it

 

login as  user added to the external_provider field on case record

you should be able to see that record

 

Please mark as Correct Answer/Helpful, if applicable.

ServiceNow Developer

Thanks & Regards,
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB

Please mark as Correct Answer/Helpful, if applicable.