When a Sales Order comes in from an SCA site, a Wo...
# suitescript
e
When a Sales Order comes in from an SCA site, a Workflow automatically transforms it to a Cash Sale; in a
beforeSubmit
User Event on the Cash Sale, I am swapping one Item in the
items
sublist for another (specifically changing a Service Item to an Item Group). The swap works just fine, but when I do that, it breaks the
createdfrom
link on the Cash Sale back to the Sales Order. Even setting
createdfrom
manually does not work. Why does the
createdfrom
link break when I change an Item line? How can I maintain it?
b
what does the code look like
e
The only change I make to the record is this:
Copy code
context.newRecord.setSublistValue({
  sublistId: 'item',
  fieldId: 'item',
  line: 0,
  value: 123 // Item Group internal ID
});
b
that change virtually guarantees that there is a mismatch between the cash sale and the sales order
e
We're aware
b
that line still has fields like orderdoc and orderline that is linking it to the sales order
e
And swapping the Item clears those?
b
it doesnt, you arent in dynamic mode
e
Correct
But the
createdfrom
link absolutely gets broken
b
if there is a mismatch, ,there is no link
someone screwed up and netsuite makes the safe play of assuming its not actually linked
e
Understood, so better to change the Sales Order before the transform. Thanks
f
I think I would lose the workflow. Among the good reasons for that are change management, but you'll also likely have more granular control of this process when you isolate to a single script vs. a workflow with UE scripts, etc.
e
That's not up to me