1

I am trying to script a work order completion in Netsuite but it is returning

"SSS_INVALID_SUBLIST_OPERATION - You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist."

Here is my code.

function preRequest(datain){
//var id = 514752;
//var sn = KQ0006608;
var record = nlapiTransformRecord('workorder', datain.id, 'workordercompletion');
record.setFieldValue('quantity', 1);


var subrecord2=record.createSubrecord( 'inventorydetail');
subrecord2.selectNewLineItem( 'inventoryassignment' );
//subrecord2.selectLineItem('inventoryassignment', 1);   
subrecord2.setCurrentLineItemValue('inventoryassignment', 'receiptinventorynumber', datain.sn);
subrecord2.setCurrentLineItemValue('inventoryassignment', 'binnumber', 25);   
subrecord2.setCurrentLineItemValue('inventoryassignment', 'quantity', 1);

subrecord2.commitLineItem('inventoryassignment');

subrecord2.commit();

record.commitLineItem('inventorydetail');


nlapiSubmitRecord(record);


}

I have in good faith gone through their documentation and know what the error is and what might be causing it but I don't know how to fix the code so it will submit the record. Any help would be awesome!

EDIT: Another clue is that Netsuite is treating the Quantity to Build field ('quantity' in my code) as a sublist. This is the root cause of the error. Fixing this will fix my code. Just not sure how.

EDIT: See Work Order Completion UI page for reference.Work Order Completion UI Page

quarks
  • 33,478
  • 73
  • 290
  • 513
jpalbert
  • 21
  • 1
  • 4
  • can you check if the work order assembly item has use bins checked? what is quantity sublist - what are its sublist fields, I don't see it anywhere on record browser? – prasun Nov 07 '15 at 06:27
  • Use bins is checked. Under the record browser it would be Quantity and yes it isn't a sublist but it is under the Assembly Detail body field. – jpalbert Nov 07 '15 at 16:55
  • I used the same code as above, it worked worked in my test account like a charm. Please check all mandatory fields on form are supplied. And, are there any other user event deployed on work order completion record type, who knows they might have a bug? – prasun Nov 07 '15 at 17:47
  • Interesting that it worked for you. What type of function did you use, (GET, POST, PUT?) Also what were your mandatory fields in your completion form? Thanks for your help so far! – jpalbert Nov 07 '15 at 21:22
  • I used GET though, but should work for any HTTP verb that RESTlet supports. for me mandatory fields were body fields 'startoperation' and 'endoperation' .do you have any user event on work order completion? – prasun Nov 08 '15 at 02:03
  • No user events at all. I am going to upload an image of the Work Completion UI entry form. – jpalbert Nov 08 '15 at 02:35
  • Are you able to create completion record from UI for the work order along with inventory detail?? – prasun Nov 08 '15 at 03:47
  • I can create a completion from the UI with the same information. I go back and delete it when I want to test it from a REST client so it isn't a problem with already existing. – jpalbert Nov 08 '15 at 06:29
  • can you join netsuite room in stack overflow chat? – prasun Nov 08 '15 at 06:42
  • I don't meet the 20 rep threshold to chat yet, so no. – jpalbert Nov 08 '15 at 16:31

3 Answers3

1

Wow so I fixed it!!!

First off the Trace Error I was receiving was "validatePredecessorCompletedQuantity" which was telling me something I didn't understand at first but since the user, prasun, was able to get my code to work on his Netsuite test environment that led me to believe that it wasn't a code issue but a Netsuite setting. So which one?

I looked for Work Order Completion Validation in Netsuite documentation and found a slideshow for validation for Work Order Completions. I changed my setting under Accounting Preferences-Order Management-Work Orders, in Setup Manager to No Validation, whereas it was Require Confirmation Before Saving which was why for some reason it didn't let me proceed. It needs confirmation which my code isn't providing.

tl;dr

Go to Setup->Setup Manager->Accounting->Accounting Preferences->Order Management->under "Work Orders" header change Check Completed In Prior Operations During Operation Completion to "No Validation"

Final Question:

Is there a way to adapt my code to allow for Validation (which is useful!) and not have to change that setting?

jpalbert
  • 21
  • 1
  • 4
0

If I recall correctly, the work order has two places where you can specify the Inventory Detail record. One is at the header with is for the Assembly Item being built and another is at the line item level for the components of the Assembly Item.

I believe 'inventoryassignment' field is for the header field which is why you are getting the error. Try using 'componentinventorydetail' instead.

Rusty Shackles
  • 2,802
  • 10
  • 11
  • I thought it was that too at first. However the Inventory Detail is in my body field for the Work Order Completion entry form. From Netsuite's documentation. "When creating/assessing a subrecord from the body field, use inventorydetail as the internal ID for the fldname parameter. When creating/accessing a subrecord from the sublist field on the Components sublist, use componentinventorydetail as the internal ID for the fldname parameter." – jpalbert Nov 07 '15 at 23:52
  • the same code above works for me, so I would disagree with your answer. – prasun Nov 08 '15 at 02:05
0

When i had this error, it was because in the record type (customerpayment) I was trying to create a sublist item row rather than transform from an existing record (invoice) and edit its auto populated 'apply' sublist items.

Hayden Thring
  • 1,718
  • 17
  • 25
  • How did you solve it in customerpayment? This is my json: `"apply":{ "items":[ { "amount":12.06, "apply":true, "doc": { "id": 5517 } } ] }` this is my error `"detail": "Error while accessing a resource. You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.", "o:errorPath": "apply", "o:errorCode": "USER_ERROR" ` – RcDEV Oct 15 '21 at 12:57
  • Is there more to your json than that ? – Hayden Thring Oct 17 '21 at 08:42
  • Yes, please check my question: https://stackoverflow.com/questions/69576758/how-to-pay-a-specific-invoice-in-netsuite-using-customerpayment – RcDEV Oct 17 '21 at 21:56
  • ok i posted an answer – Hayden Thring Oct 18 '21 at 05:21