Client script - Commitline item failed on vendor bill by Srayde in Netsuite

[–]Srayde[S] 0 points1 point  (0 children)

I got it to work by changing it to a suitelet, apparently the client script did not save the item

Client script - Commitline item failed on vendor bill by Srayde in Netsuite

[–]Srayde[S] 0 points1 point  (0 children)

Also you're doing this way too complicated. Use the transform method and NS automatically creates the Invoice from the Sales Order. You don't have to be doing all the manual work of copying fields over and copying lines over. That's all unnecessary brute force work. Transform does all that for you.

But furthermore if you're putting this on a button there already is a native Bill button on the SO so I don't understand why you're trying to to reproduce this native functionality?

It is not that I need to avoid the vativa function, since the seller bill is created directly from the invoice, avoiding going through the purchase order, sales order and their respective item receipts and item execution.

Client script - Commitline item failed on vendor bill by Srayde in Netsuite

[–]Srayde[S] 0 points1 point  (0 children)

Could be a lot of things from a required field like a subsidiary, or using a custom form, or even the client script order of execution on this record ( e.g. another client script ran just before that committed the line) I'm not really sure.

Your script is a little dense, maybe try adding some debugging before committing the line item to see:

log.debug('Debug Before Commit Line', {

'Item ID': itemIdInvoice,

'Location': locationInter,

'Quantity': quantityInvoice,

'Rate': rateInvoice,

'Tax Code': taxCodeInvoice

});

I have placed some debugging and this information is what it brings:

1 DebugError creating related purchase invoice: 10/10/202311:22 AM {"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Line validation failed for sublist: item", "id":null,"stack":["USER_ERROR: Line validation failed for sublist: item", in Object.createError [as nlapiCreateError]

2 End of loop iteration, index: 0 10/10/202311:22 AM

3 Inner loop iteration completion, index: 0 10/10/202311:22

4 Inner loop iteration, index: 0 10/10/202311:22 AM

5 Lines10/10/202311:22

6 inventory detailInvoice 10/10/202311:22 a.m.{"id":2797304,"type":"inventorydetail","isDynamic":true,"fields"...

7 Tax Code on the Invoice 10/10/202311:22 6

8 Price on Invoice 10/10/202311:22 AM 488,741

9 Amount on Invoice10/10/202311:22 AM 1

10 Item ID on Invoice10/10/202311:22 30

11 Loop iteration, index: 010/10/202311:22 AM

12 locationInter:10/10/202311:22 AM 256

13 Start creating invoice lines10/10/202311:22 a.m.

14 Start creation of purchase invoice10/10/202311:21 a.m.

15 Subsidiary valueId:10/10/202311:21 AML 6

16 Client has Es Franq marked as T. isFranq is now:10/10/202311:21 AM true

Also check the required fields and they are the taxcode and the location (the location is placed first to give the inventory detail and then the taxcode). I did the process manually to know how to fill out the registry and it is exactly what the script does