adavies
02/26/2020, 5:16 PMlineuniquekey
, linesequencenumber
, or line
do the trick.stalbert
02/26/2020, 5:17 PMadavies
02/26/2020, 5:17 PMstalbert
02/26/2020, 5:18 PMstalbert
02/26/2020, 5:19 PMexport 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!'
}
adavies
02/26/2020, 6:53 PMorderline
isn't searchablebattk
02/26/2020, 6:54 PMbattk
02/26/2020, 6:54 PMbattk
02/26/2020, 6:55 PM