Ismemberof is not working in scoped app

knopbrent
Tera Contributor

Hi Community

 

A field should be editable to the members of the Assignment group(assignment group backend value = network_security_group) . I wrote the below mentioned code on a Field level Write ACL but it is not working. Can you please take a look and let me  know where am I going wrong ?

 

The first 2 conditions are working but the 3rd condition for "ismemberof" is not working. 

Quick question - "ismemberof" doesnot work in scoped app ??

 

if (gs.hasRole('x_cld_fsg.FSG_CLD_SECURITY') || current.network_iga_contact == gs.getUserID() || gs.getUser().isMemberOf(current.network_security_group.getDisplayName().toString())) {

    answer = true;
} else {
    answer = false;
}

 

Thanks in advance

10 REPLIES 10

Karan Chhabra6
Mega Sage
Mega Sage

Hi @knopbrent ,

 

isMemberOf() does work in scoped apps, please use getDisplayValue and you are missing a parenthesis at the start

if ((gs.hasRole('x_cld_fsg.FSG_CLD_SECURITY') || current.network_iga_contact == gs.getUserID() || gs.getUser().isMemberOf(current.network_security_group.getDisplayValue())) {

    answer = true;
} else {
    answer = false;
}

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

 

Hi @Karan Chhabra6 

 

I have tried with "getDisplayValue() and also added the parenthesis, it did not work. Is there any other way that we can implement this ? or am I missing something ?

 

@Ankur Bawiskar  - Do you have any idea ? where am I going wrong ?

 

 

Riya Verma
Kilo Sage
Kilo Sage

Hi @knopbrent ,

 

Hope you are doing great.

 

"ismemberof"  should work as expected in scoped app too. However, please ensure that you have the necessary access controls and configurations in place for the scoped app to function correctly.

below script works in PDI :

 

var current = new GlideRecord('incident');
current.get('8d4cbaab97722110466eb666f053af8c');

if (gs.getUser().isMemberOf(current.assignment_group.getDisplayValue())) {
    var answer = true;
} else {
    var answer = false;
}

gs.info(answer);

 

PFB screesnhot:

RiyaVerma_0-1687980414699.png

Try incorporating the same add on condition in your script, something as like below :

 

if(gs.getUser().isMemberOf(current.network_security_group.getDisplayValue()) || gs.hasRole('x_cld_fsg.FSG_CLD_SECURITY') || current.network_iga_contact == gs.getUserID()) {

    answer = true;
} else {
    answer = false;
}

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi @Riya Verma 

 

I am getting the below mentioned message after executing the script

 

x_cld_fsg: false