2
votes

I'm trying to get an app I'm working on to display all associated user notes for a given Customer record (as it appears on the UI Customer record page in Netsuite proper).

To that end, I've set up a Netsuite RESTlet to return a list of internal ids for associated Note records given a Customer internal id.

I've set up a simple search in the RESTlet script:

function get_notes(params) {
  log("GET params", JSON.stringify(params));

  var filters = [
    new nlobjSearchFilter('internalid', 'customer', 'is', params.id)
  ];

  var columns = [
    new nlobjSearchColumn('internalid'),
    new nlobjSearchColumn('note'),
  ];

  var search = nlapiCreateSearch('note', filters, columns);
  var notes = search.runSearch().getResults(0, 3);
  return notes;
}

function log(msg, details) {
  nlapiLogExecution('DEBUG', msg, details);
}

The script works as expected, but the problem is that this search ONLY returns Notes for which the author field (which is a user internal id) matches the internal id of the user performing the search. Meaning - you can only search for Notes for which you are the author.

I have been informed that this is a 'feature' of Netsuite for some unfathomable security reason.

I need to be able to get a list of all the associated Note ids, not just those for which the user making the request is the author.

Any ideas on a workaround to get at all the associated Notes? A different way to structure the search? Some kind of secret way to define your own custom Search Joins?

I can't even find documentation on this behavior (blocking Note searches from non-authors). Perhaps someone knows how to override it at the admin level?

I'm not quite ready to admit that this is impossible yet.

NB: User Note is a Note-type record associated with the Customer record, not a field on Customer record, so I can't access it directly from Customer. There is also not a Search Filter or Search Join for Note or User Note.

2
Why are you using a restlet? What is the context of the search?bknights

2 Answers

1
votes

Using RESTlets you cannot get the notes of other users unless you invoke the RESTlet using credentials/tokens of roles like Administrator/Full Access. RESTlets always runs in the context of current user.

One alternative to do that, if you really got to achieve this any how:

1) Create a user event script on customer which creates a custom record that simulates the functionality of system notes.

2) Make sure that the RESTlet user roles have full level of access on the custom record and make customer as parent of your custom record.

3) In your RESTlet return the custom records.

1
votes

Basically RESTLETS always run as the user who invokes them. If you can use a Suitelet for this you can set that up to run as Administrator and can return any Notes you can craft a search for.

Are you actually needing a Restlet ? i.e. Are you calling this from an external application or are you trying to add functionality in the NS GUI? If the latter then you can easily use a Suitelet.