Hi All, has anyone managed to approve/cancel Vendo...
# suitescript
a
Hi All, has anyone managed to approve/cancel Vendor Return Authorization programmatically? This transaction type seems to differ from the others. Typically ApprovalStatus field (or OrderStatus, etc) can be used to change the general transaction status. But for VRA ApprovalStatus is just not visible during editing mode, it's available only during creation (see the screenshots #1&2). NetSuite only provides 2 hard-coded UI buttons - Approve/Cancel, but looks like they can't be called programmatically (screenshot #3). This leads to inability to change VRA status by any method - SuiteScript, Workflows, SuiteTalk, nothing works. Is there any workaround? Or is it just a strange NetSuite limitation which just complete restrict programmatic status change for some transaction types? The closest thing I could find is NetSuite confirming that SalesOrders just can't be cancelled programmatically - https://stackoverflow.com/a/36264879
m
In what aspect are you trying to do this from, client script or server side like a user event or suitelet? Even though the field isn’t seen in the UI doesn’t mean it’s unavailable. If you add to the url &xml=t then it should show you all the data fields available.
e
Cancelling sales orders can be done programmatically but it has to be via a client script approach.
a
@Matt Carter I am using server side user event script. sure, VRA has status fields exactly as other transaction types:
Copy code
<orderstatus>A</orderstatus>
<status>Pending Approval</status>
<statusRef>pendingApproval</statusRef>
but those fields seem to be read-only for for every edit method except UI hard-coded buttons. I have a working script which changes the status (e.g. for Sales Order from Pending Approval => Pending Fulfillment).
Copy code
var transactionRecord = record.load(...)
transactionRecord.setValue({fieldId:'orderstatus',value: 'B'});
transactionRecord.save();
when I try to do the same for VRA this logic is completely skipped w/o any error. I tried any field<>value combinations for orderstatus, status, statusRef fields Also tried setting them all together, one by one. btw when I try to use the same script for cancelling SO (set orderstatus = C) then I get
You have entered an Invalid Field Value C for the following field: orderstatus
that's why I suspect NetSuite might have implementation differences between different transaction types.
@Eric B client script approach doesn't work for my requirements, but maybe you can elaborate on how SO cancellation could be achieved anyway? the only client-side approach I found is redirecting user to /app/accounting/transactions/salesordermanager.nl?type=cancel&id=12345 but this is ugly and unreliable at all
m
Gotcha, yeah there are definitely differences between the transactions. It’s been a while since I had to deal with that on a sales order, but I think the change has to be on the status or statusref fields sometimes when doing by script. Always had to make a guess and try a couple approaches to get it to work.
Through a client script, with DOM manipulation you should be able to grab the cancel button html and fire off its click event.
e
Yes cancelling sales orders is very manual and ugly. I have a Suitelet that allows users to select orders to be cancelled and the process loops through the internal ids that were selected and makes an https.get.promise call to the URL you just mentioned basically mimicking that client-side user click. The caveat is that it can only do 50 orders at a time before the browser thinks that it has timed out.
a
ok, for VRA - looks like that inability to change orderStatus during edit is a NetSuite's bug. The same problem reported by other person: https://netsuiteprofessionals.com/blog/question/vendor-return-authorization-approval-workflow/ as for cancelling SO - I've tried everything, both from Server SOAP and server-side SuiteScript. The same validation error "Invalid orderstatus reference key C". The last server-side hack I can think of is using SuiteScript's http module to send get request to /app/accounting/transactions/salesordermanager.nl?type=cancel&id=12345 But NetSuite responds with Login Page and I guess it will be impossible to bypass that authentication?
n
You don't usually change a status unless it's something like an Item Fulfillment. For example, You may find you need to set a checkbox such as "isclosed" on each of the item lines to "Close" a transaction. Not sure about "Cancel" in this scenario, maybe you mean Close? or maybe "Closing" would work in this scenario. https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2023_1/script/record/vendorreturnauthorization.html search "isclosed" ^^ Maybe you can confirm that and it's be the solution.
a
@NElliott I am talking about subset of statuses like Pending Approval/Approved/Rejected. NetSuite has a general pattern for exposing a separate form field (like Approval Status, OrderStatus, Status, etc, see screenshot) which control transaction general status. Field change can be made by any method - UI, script, workflow, SOAP, REST, so there is plenty of room for automation. this works for core transactions (like bills, POs) but for other rare transaction (like SO, VRA) this pattern seems to be partially supported. You're right, SO status can be closed by closing all the lines, but Closed SO != Cancelled SO. Using Closed status is quite an unsatisfying alternative. But for VRA such trick doesn't work at all. Can't really "approve" them programmatically at all. Can't close VRA because there is no Closed column implemented for expense lines.
n
I think perhaps you misunderstood. When you press a button that changes the status of a record there's often other things that happen behind the scenes it's not just that the status updates. My point was that programmatically you may have to do several other things that affect the status and thereby update the status. Yes I'm fully aware that Closed != Cancel... In any case, good luck. 😉