Boris Yasen
11/16/2023, 9:34 AMconst createShipAddress = (customerId, addressObj) => {
let rec = record.load({
type: record.Type.CUSTOMER,
id: customerId,
isDynamic: true
});
rec.selectNewLine({
sublistId: 'addressbook'
});
// Set an optional field on the sublist line.
rec.setCurrentSublistValue({
sublistId: 'addressbook',
fieldId: 'label',
value: addressObj.addressName
});
// Create an address subrecord for the line.
var subrec = rec.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
subrec.setValue({
fieldId: 'country',
value: addressObj.country
});
subrec.setValue({
fieldId: 'addressee',
value: addressObj.addressee
});
subrec.setValue({
fieldId: 'city',
value: addressObj.city
});
subrec.setValue({
fieldId: 'state',
value: addressObj.state
});
subrec.setValue({
fieldId: 'zip',
value: addressObj.zip
});
// Save the sublist line.
rec.commitLine({
sublistId: 'addressbook'
});
// Save the record.
try{
var recId = rec.save();
log.debug({
title: 'Record created successfully',
details: 'Id: ' + recId
});
} catch (e){
log.error({
title: e.name,
details: e.message
});
}
}
However, could I know how to get the ID address of created address please?
Do I need to create a customer Saved Search for address subrecord?battk
11/16/2023, 1:13 PMBoris Yasen
11/16/2023, 3:06 PMsoRec.setValue('shipaddresslist', addressId);
However, the SO Ship To Select is Custom, even the SHIP To shows the correct address information.
Could I know how to set that SHIP TO SELECT value to the just created address please?battk
11/16/2023, 3:07 PMbattk
11/16/2023, 3:07 PMbattk
11/16/2023, 3:07 PMBoris Yasen
11/16/2023, 3:08 PMBoris Yasen
11/16/2023, 3:11 PMbattk
11/16/2023, 3:13 PMbattk
11/16/2023, 3:13 PMbattk
11/16/2023, 3:14 PMbattk
11/16/2023, 3:14 PM