How to get the subrecord id ?

 

/**

* @NApiVersion 2.0

* @NScriptType UserEventScript

* @NModuleScope SameAccount

* @appliedtorecord employee

*/
define([‘N/record’, ‘N/https’], function (record, https) {

function handleAfterSubmit(context) {

var newRecord = context.newRecord

var internalID = newRecord.id

var companyName = newRecord.getValue(‘companyname’)
// Retrive a value from the sublist line
var labelValue = newRecord.getSublistValue({

sublistId: ‘addressbook’,

fieldId: ‘label’,

line: 0

})
var addressId = newRecord.getSublistValue({

sublistId: ‘addressbook’,

fieldId: ‘addressid’,

line: 0

})
var addrTextValue = newRecord.getSublistValue({

sublistId: ‘addressbook’,

fieldId: ‘addressbookaddress_text’,

line: 0

})
// Retrieve the subrecord associated with that same line.
var subrec = newRecord.getSublistSubrecord({

sublistId: ‘addressbook’,

fieldId: ‘addressbookaddress’,

line: 0

})
var cityValue = subrec.getValue({

fieldId: ‘city’

})
var countryValue = subrec.getValue({

fieldId: ‘country’

})
var attentionValue = subrec.getValue({

fieldId: ‘attention’

})
var addr1Value = subrec.getValue({

fieldId: ‘addr1’

})
var addr2Value = subrec.getValue({

fieldId: ‘addr2’

})
var stateValue = subrec.getValue({

fieldId: ‘state’

})
var zipValue = subrec.getValue({

fieldId: ‘zip’

})
return {

afterSubmit: handleAfterSubmit

}

})

 

Here the addressId is null always during the create but there is value during the update.

How can I use the addressId during the create?

Rookie Asked on September 24, 2021 in How To's.
Add Comment
0 Answer(s)

Your Answer

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