Delete sales order with invoice using console

Hi everyone,

I’m trying to delete billed sales order with invoice recored using console by this code:

var searchResult = nlapiSearchRecord(‘salesorder’, 5823);
for (var i = 0; i < searchResult.length; i++) {
    console.log(i, ‘start’, searchResult[i].getId());
    nlapiDeleteRecord(searchResult[i].getRecordType(), searchResult[i].getId())
    console.log(i, ‘end’, searchResult[i].getId());
}
it gives me  this error:

“nlobjError {id: undefined, code: “TRANS_IN_USE”, details: “This transaction cannot be deleted because it is l…>here</a> to see the list of linked transactions”

so what i can do? i need to delete sales order and invoice , i tried to use the code to delete invoice first but again same error appeared

 

Rookie Asked on April 20, 2020 in SuiteScript.
Add Comment
1 Answer(s)

You would need to delete every transaction related to the 2 first. You can click the link in your error message to see a list of the related transactions that must be deleted first. Alternativly you can view the related records subtab of the sales order or invoice. All related records need to be deleted first before you can delete the parent transaction.

Intermediate Answered on April 20, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors: Tipalti