ACL Script

CV1
Tera Contributor

Hello All,

Creating  a read ACL on cmn_location for snc_external so that on CSM portal the use can see case location for only that account.

This is the script

mylocation(current);

function mylocation(current){
    if(current.company == gs.getUser().getRecord().getValue('account')){
        return true;
    } else {
        return false;
    }
}
 
plz advise what is wrong as its not working.
TIA
7 REPLIES 7

ahefaz1
Mega Sage

@CV1 ,

 

Can you try setting the answer variable like below:

 

answer = mylocation(current);

function mylocation(current){
    if(current.company == gs.getUser().getRecord().getValue('account')){
        return true;
    } else {
        return false;
    }
}

 

Please accept solution OR mark helpful.

 

Thanks,

CV1
Tera Contributor

Hi @ahefaz1 ,

 

I tried above but when i am loging , 

 

answer = mylocation(current);
gs.log("Testing location = " + answer);

function mylocation(current){
    if(current.company == gs.getUser().getRecord().getValue('account')){
        gs.log("Testing COMPANY = " + gs.getUser().getRecord().getValue('account'));
        return true;
    } else {
        return false;
    }
}
 
RESULT:
Testing location is returning false
and Testing COMPANY is returning undefined.
 
The table cmn_location does not have field  "Company" but has field "Account".
 
Plz advise.

@CV1 ,

 

I did not find a account field on the cmn_location table OOTB.

Is this a custom field on your instance??

 

Your logs are returning the correct results.

gs.getUser().getRecord().getValue('account') - this will not work

gs.getUser().getRecord() - returns the user table record. The account field does not exist on the user table.

The account field you are looking for in CSM is on the "customer_contact" table.

 

ahefaz1_0-1707623355218.png

 

OOTB to map the location in CSM the cmn_location table is not used. Is this something that has been customized on your instance??

 

The location is stored directly on the customer account table:

 

ahefaz1_1-1707623418734.png

 


Please accept solution OR mark helpful.

 

Thanks,

CV1
Tera Contributor

@ahefaz1 ,

yes we have Account on Table: cmn_location  which is a reference to Table : customer_account

How do I change the script to work

TIA