Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

netsuite - Create a RESTlet that can access Server Script Log record type

Our company isn't satisfied with the tools NetSuite gives you to access script logs for a number of reasons. So I wrote a function that searches the 'scriptexecutionlog' record type, which works fine in the debugger when I am logged in as admin. So I plopped it into a RESTlet, and hit my endpoint, but authenticated as a non-admin, and it always returns no results. I'm assuming this is because only admins have access to the 'scriptexecutionlog' record type. (Exact same code, so it's not like a typo or anything. I'm positive on that part)

So my first thought was to just create a saved search and check the 'Run Unrestricted' checkbox. This would allow me to use 'search.load' with the new saved search id, from within a RESTlet that is being called by a non-admin user. That's precisely what the 'Run Unrestricted' checkbox is for, yet it doesn't work. If I load that search in my RESTlet, it again returns no results.

So my next choice was to create a new Access Token, and select 'Administrator' as the role, but apparently you can't do that. 'Administrator' isn't one of the available options. So I thought I'd create a new role that had access to the 'scriptexecutionlog' record type, but for the life of me I can't find a permission that allows that.

So I'm stuck. It seems like a RESTlet is unable to query the 'scriptexecutionlog' record, simply because that requires administrator privileges that can't be added to other roles, and you can't add the Administrator role to User Access Tokens. It's a catch 22.

To sum up, I think if any of these questions can be answered, I'd be good:

  • Is there a permission setting for accessing the scriptexecutionlog record type? If so, where?
  • Is there a way to select 'Administrator' as the Role when creating an Access Token?
  • Is there a way to create a saved search that searches on the 'scriptexecutionlog' record type, that can be loaded from code not being run as admin, so it actually returns results? (in other words, make the 'Run Unrestricted' checkbox work like it's supposed to)

Thanks in advance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am able to access script execution logs via a RESTlet call. You can control the access your RESTlet has by controlling the role that you use for your access token.

I have included a screenshot below of the permissions I have granted to my role that is able to access the script logs. The important line is the one that says "SuiteScript" with the access level set to "View". If I remove that line, then I get an INSUFFICIENT_PERMISSION error when performing the script notes search.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...