Hello Everyone!! I have following code ```/** *...
# suitescript
h
Hello Everyone!! I have following code
Copy code
/**
 
* @NApiVersion 2.0
 
* @NScriptType UserEventScript
 
* @NModuleScope SameAccount
 
* @appliedtorecord customer
 
*/
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
 
}
 
})
I want to use the addressId but during the create of customer from the ui it is always null but during the update it returns the value. How can I use the addressId during the create of customer? I am new to this so help is appreciated.
b
use record.load to load the record again
records in afterSubmit dont reflect changes that occur after the record is submitted, like the generation of ids
the only one that updates is Record.id, which you will need to use to get the internal id of your customer
alternatively you can use N/search or N/query to get your data
h
Thanks @battk record.load was what i needed.
@battk can you share some example or documentation for making this script to have multiple address.
b
dont know what you are asking
h
If i add the customer with single shipping address it is fine so if we add multiple shipping address I want to send all the address in the payload
b
h
👍