RE: How to Execute a Client Script as Administrator

Hi, does anyone know how you can execute a client script always as an admin, regardless of the logged in user? I have a client script applied to sales orders that sets fields to mandatory when the customer field is changed. However, the script needs to admin permissions to run successfully.

mmascitto Beginner Asked on November 1, 2019 in SuiteScript.
Add Comment
1 Answers

Client scripts by nature must use the user role.

Setting fields mandatory shouldn’t require admin

Advanced Answered on November 1, 2019.

Actually, it doesn’t look like it’s my script that’s causing the issue. In a role that doesn’t have employee permissions NetSuite is throwing this error whenever the customer field on the sales order is changed, which happens to be one of my script entry points too, and it’s prohibiting my script from running.

RE: How to Execute a Client Script as Administrator

I’m running the exact same functions on pageInit and my script works fine. It’s just fieldChanged that’s a problem. I turned off my script and still got the same error. I also pushed my script to the top of the execution list and still got it. This tells me it’s not my script nor is it another script that’s causing the problem. If it was another script, mine should have executed before the error was thrown. It must be something native, maybe sourcing that occurs when the customer is changed and the sourcing requires employee access. I’m not sure what it is exactly, though, and it’s preventing my script from running.

on November 2, 2019.

Can you open that stack trace and perhaps find where it is coming from?

 

You can always go the route of turning off every single script on the page one by one until you find what is causing it. I can’t think of anything native about setting a customer that would throw that type of error.

 

You aren’t setup in some strange role where the role has access to sales orders but not customers? I don’t even know if that is possible, but if it was, clicking the customer does some native sourcing from the customer record and it might be doing it via something like search.lookupFields and toss the error there. But like I said, that’d be predicated on having one really strange role setup.

on November 4, 2019.

Your likely cause then is the Sales Rep field. Maybe try unchecking the role permission “Restrict employee fields”?

on November 5, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.