I am trying to remove vicarious email permission f...
# suitescript
r
I am trying to remove vicarious email permission from certain employee record via a userevent script. can some1 explain me, why it isn't working?
Copy code
count = currentRecord.getLineCount('empperms');
if (count != 0) {
    for (var i = 0; i < count; i++) {
        var sublist_value = currentRecord.getSublistValue('empperms', 'permkey1', i);
        if (sublist_value == "ADMI_VICARIOUS_EMAILS") {
            index = i;
            flag = true;
        }
    }
    if (flag) {
        currentRecord.removeLine('empperms', index); // (issue is in this API I believe)
    }
}
b
generally you need to do better than
it isnt working
too much falls under not working
r
code is reaching inside the if block
Copy code
if (flag)
But Api removeline is not doing anything. There is no error.
b
might have better luck setting the access level to none
r
That is the alternative solution I used. Still couldn't able to figure out why the line was not getting removed from the sublist.
a
@raghav Sometimes you need to remove lines in reverse order or it does not work, try to create an array of lines indexes to remove, sort that array descending and then remove the lines in that order.
r
@alien4u i just had to remove one particular sublist line. What I figured out is the API only works in client script. And not userevent script. In netsuite help it's written that it works in both client and server side scripts. But in Oracle documentation only client script is mentioned.