Is there a reliable column/join I can use to map I...
# suitescript
a
Is there a reliable column/join I can use to map Item Fulfillment lines to Sales Order lines they were created from? I can't rely on basic line numbers. It doesn't look like
lineuniquekey
,
linesequencenumber
, or
line
do the trick.
s
I create a custom field for this
a
Unfortunately I'm not able to create a custom field in this situation
s
AFAIK there is no reliable key to tie lines between records.
should you decide that a custom field is not impossible:
Copy code
export function beforeSubmit(context: EntryPoints.UserEvent.beforeSubmitContext) {
    if (context.type === context.UserEventType.EDIT || context.type === context.UserEventType.CREATE) {
      const newRecord = new InterCompanyTransferOrder(context.newRecord)
      // only consider lines without line numbers - on CREATE that will be ALL the lines, on EDIT only added
      // but we also need to consider deleted lines     
      // Get the Current Line Count Max value, else default to zero if no lines are populated
      // note to handle deletions we get the max from the _old_ record
      let max = _.max(
            _.map(context.oldRecord ? new InterCompanyTransferOrder(context.oldRecord).item : 
                  newRecord.item, 'custcol_rsm_unique_line_number')) || 0        
        // add numbers to lines without a value
        _(newRecord.item)
          .reject(i => i.custcol_rsm_unique_line_number)
          .forEach(line => line.custcol_rsm_unique_line_number = ++max)
      }
    }
    return 'Shazam, line numbers updated!'
  }
a
Even if I get both of those fields, how can I map them together?
orderline
isn't searchable
b
if you are starting from a search, the applied to transaction join is linked to the matching line on the sales order
you can use columns liked applied to Transaction: Line ID to get the line id of the matching sales order line
depending on your needs, applied to transaction : Line Sequence Number may be more useful