0

I need to get a lookup fields value from a line item on an SO and then update the corresponding line item in a PO. Fetching the value is not a problem, I'm using

newSite = record.getSublistValue("item", "custcol_site", lineNum)

to get the value - this returns the id of the lookup field object. However when I then try to update the field value on the PO using

loadedTransaction.setSublistValue({
    sublistId: "item",
    fieldId: "custcol_site",
    value: newSite,
    line: lineNum
});

Nothing happens, I don't get an error, however the field doesn't update either. How can I update the field using this ID value I've already fetched?

I'm also updating a number of other fields without issue following the same pattern, it's only the lookup field that's not updating successfully, so "lineNum" and fieldIds are not the problem as far as I can tell, I must just not be sending the correct information to update the lookup, however I can't find somewhere to tell me what information to send through.

djbrazzy
  • 21
  • 4

2 Answers2

0

Inferring from the name loadedTransaction that you have called record.load() to retrieve that reference, you'll also need to then call loadedTransaction.save() to commit your changes to the database.

erictgrubaugh
  • 8,519
  • 1
  • 20
  • 28
  • Yep, I'm saving the transaction and the other sublist fields are being updated correctly, only the lookup field isn't being updated. – djbrazzy Nov 14 '20 at 22:40
  • Compare the permissions on the custom column to the permissions the script is using. If the field is Inline you can't update it. Beyond that I'm out of suggestions. – erictgrubaugh Nov 15 '20 at 02:41
  • In additon to for sale, for purchase also check that the custom field isn't limited only to certain items. – bknights Nov 16 '20 at 01:15
0

Are you committing the line item before saving the record ? recordObj.commitLine('item');

Addy
  • 67
  • 3