Create Transfer Order through Restlet in Suitescript 2.x - netsuite

All,
From a third party application, I am triggering a restlet in 2.x. And that restlet invokes a Map/Reduce script to create Transfer Orders. This is not creating transfer orders and throwing "An unexpected SuiteScript error has occurred". It looks the error is occurred due to the role I used. I tried internally through AJAX requests and find the script is working and creates Transfer Order records. So I understand the issue is due to role which the restlet uses. Can anyone help me, which specific permission I needed to add to the roles to create transfer orders?
Thanks in advance!
Babin

Related

Implementing logging and retry mechanism in netsuite suitescripts

I am in need of a way to implement the error logging and providing a way to the admins to rtry any failure that occurs within a suitescript.
Here are my thoughts on the implementation:
Lets say for restlet i can log the datain, or the incoming data in any userevent script in a text file along with its status as success or failure. Later have a scheduled script to process that text file that may send those errors to my .Net Api and I can provide a way for Admins to retry.
Could anyone suggest me how its normally done in netsuite projects?
For similar systems, I typically advise you create Custom Records. Your custom records can have a field to store the raw data (JSON, xml, etc) as well as a Status (Succeeded, Failed, Retry, etc). You could consider retry mechanisms like having a User Event on the Custom Record that immediately retries upon creation of the record, then if that fails have a Map/Reduce that runs on a regular schedule to clean things up.
If the native Execution Logs aren't providing enough functionality for you in that respect, you can add a Custom Record for "logging" as well, but I'd suggest trying to use the native logs first. The Script Execution Logs UI provides reasonable searching/filtering capabilities.

"Could not determine customer compid" USER_ERROR in netsuite sandbox

I have a User event which calls a restlet using nlapiRequestURL() method. The URL, headers and authorization seems fine but it returns an error message saying - "Could not determine customer compid". Has anyone had the same issue earlier or know how to work around with this. Any help is appreciated.
We see this occassionally when a Suitelet or Restlet URL isn't specific enough for NetSuite to know which company is trying to call the URL. The script id by itself is not enough to know the company if the user is not currently logged in to NetSuite.
You can add &compid=<YOUR NETSUITE ACCOUNT NUMBER> to the the URL to let NetSuite know which company is trying to call the specific URL.
Just adding this on because I had the same issue, you'll get the same error if you're hitting a sandbox and not capitalizing the SB in nlauth_account.
Eg NLAuth nlauth_account=XXXXXXX_SB1 instead of NLAuth nlauth_account=XXXXXXX_sb1.
We did face this issue, clearing browser cookies solved in most cases.
Sometimes the problem was persistent for about few hours and got fixed on its own.
If you're using NLAuth, be sure you use commas (not spaces) to separate the account, email, and signature fields. Using spaces gave me this error.

With suitelet's external url unable to send mail

We have an issue here. I don't know its by design or an issue that I'm only facing here. Its pretty strange that the same User Event is executing fine while I'm modifying a record through Suitelet's internal url but if I switched to external url its not working. Any guess why this is happening ?
Permission maybe? Under what role are you running the suitelet?
I got one solution for that i am calling restlet with suitelet to invoke user event. wrote some code in restlet like update fields on record type. and user event will trigger. and write mail logic in user event so mail will be sent.
Security Reasons, if your Suitelet is available without login or as you've mentioned accessible by "External URL" that means the it can be accessed by anyone that doesn't have an access to your NetSuite account. Having said that, do you want to send an email triggered by a user whom you don't know? I guess not.

logging request and response while using netsuite suitetalk

is it possible to print/log the request response while using the Netsuite API, is there any property we need to set in the nsclient.properties file that might help.
I am trying to find this so that while integrating with NetSuite, in case of any issues, I don't have to go check the API request/response logs in NetSuite.
regards,
Moin
Requests and responses are logged within NetSuite itself. You need to have the Admin role to see them.
I don't think so. I'm not pretty sure that there is any inbuilt feature in NetSuite that allows you to log the request and response of your deployed Restlet. In Netsuite there is a method called :
nlapiLogExecution(logType, title, details)
Which you can use for temporal logging/Debugging. However, it doesn't persist your logging data permanently, so you can't use the same later. Yeah, Of-course you can find many workarounds to get your task done. Create a custom record with appropriate fields for logging then inside your restlet you can write the code to create a log file for each req/resp.

Trying to send a document through a trigger

I'm currently trying to automate the process of creating a docusign document and sending it by putting it into an apex trigger. I have managed to get the docusign api (via WSDL) into my org, and now I'm trying to add the code into the trigger to send out the document. Without pasting the entire code here, I've been following this tutorial and have gotten all of the required code into my trigger. Unfortunatly, when I run it, I get this error:
11:40:49.965 (12965647595)|FATAL_ERROR|System.VisualforceException: Getting content from within triggers is currently not supported.
Trigger.OpportunityTrigger: line 109, column 1
Does this mean that it's not possible to send a document in a trigger? The tutorial sends it through a controller, is that the only currently supported method?
Thank you for any help you can give me!
EDIT:
So I've gotten past that error (using a different tutorial), and am now getting this error.
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: This User lacks sufficient permissions. User does not have the permision to the CreateEnvelopeFromTemplates method faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx
This appears to be a problem with the Docusign user I am using for sending this document. I am currently using CreateEnvelopeFromTemplates to try and send a templated document out to up to 5 recipients.
I ended up phoning into Docusign Support, and asking them about the issue. Turns out that the last error was caused by me trying to authenticate and sign into docusign with my userID not the AccountID (switched those around and the permission error went away).
Another error showed up related to not having roles setup properly in my template (fixed that by setting up the role), and now everything is working fine. I'm answering my own question to leave it as a reference to future searchers.
Create a call out from trigger
Then get the request from a rest method
Then continue to get the pagereference conten
You can find an example here

Resources