Weird permission error on searching on supportcase...
# suitescript
c
Weird permission error on searching on supportcase with joins via the company field:
Your search contains a reference to join for which you do not have a permission: Entity
There isn't a permission called Entity. I have granted View permission for Contacts, Customers, Employees, Projects and Supplies but that didn't fix it. Any ideas?
b
what are the search filters and columns?
c
Copy code
var filters = [];

filters.push(search.createFilter({
    name: 'custevent_sp_icefs_everenabled',
    operator: <http://search.Operator.IS|search.Operator.IS>,
    values: [true]
}));

if (!!prevLastModifiedDate){
    filters.push(search.createFilter({
        name: 'lastmodifieddate',
        operator: search.Operator.GREATERTHAN,
        values: [prevLastModifiedDate]
    }));
}

const results = utils.doSearch('supportcase', filters, [
    'internalid',
    'casenumber',
    'custevent_case_sched_start_date',
    'custevent_case_sched_start_time',
    'custevent_case_sched_end_date',
    'custevent_case_sched_end_time',
    'custevent1',
    'title',
    'startdate',
    'custevent_sp_description',
    'company.entityid',
    'company.companyname',
    'custevent_case_address',
    'phone',
    'custevent_sp_icefs_enabled',
    'lastmodifieddate'
]);
utils.doSearch just runs the search. It doesn't modify its parameters before passing them to the native search functionality
b
and which columns do you have to remove to remove to fix the permission error
c
company.entityid and company.companyname
b
meh, tried the code
got a invalid column on company.companyname
no permission error though
c
Weird
b
and thats on a role with 2 permissions, full run search and view case
c
Even if I remove only company.entityid and include company.companyname then I get the permission error
b
might want to simply try removing the companyname column
and leaving entityid
you might just be getting the wrong error message
c
Just tried that and got the same permission error
I contacted NS support 12 hours ago so hopefully I'll discover the answer soon. It'd be annoying to have to perform more than one search
b
you will probably want to give them simpler code
that they can use to reproduce the problem themselves
Copy code
require(["N/search"], function (search) {
  log.debug(
    "results",
    search
      .create({ type: "supportcase", columns: ["company.entityid"] })
      .run()
      .getRange(0, 1000)
  );
});