Hi community!
I am trying create an Return Authorization record in my script. But sometimes I get the next error:
{"type":"error.SuiteScriptError","name":"INVALID_INITIALIZE_REF","message":"You can not initialize returnauthorization: invalid reference 87014.","stack":["createError(N/error)","beforeSubmit(/SuiteScripts/Automated Process IF.js:116)"],"cause":{"type":"internal error","code":"INVALID_INITIALIZE_REF","details":"You can not initialize returnauthorization: invalid reference 87014.","userEvent":"beforesubmit","stackTrace":["createError(N/error)","beforeSubmit(/SuiteScripts/Automated Process IF.js:116)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
Let me explain more about my task and problem:
I am trying to automate the process of creating an RA. Instead of clicking the "Authorize Return" button in Sales Order, I created a script that should be triggered in Item Fulfilled when the "Mark Shipped" button is clicked.
As I understand it, pressing the Authorize Return button calls the record.transform function from SO to RA.
I repeated this in the script and it works correctly, I got RA from the test SO.
Only I noticed that RA can not be created from all SO, but only from those that have the following status: Billed, Pending Billing/Partially Fulfilled, Partially Fulfilled.
Also, if SO does not have an "Authorize Return" button, or if SO already has an RA, I will get the error I gave at the beginning.
Does anyone know how I can check in a script if it is possible to create an RA for a Sales Order without getting this error?