Mark
04/29/2025, 6:34 PMCeligo AI
04/29/2025, 6:35 PMAI generated answer (using internal Slack threads):To modify an address in SuiteScript 1.0 on a Transaction client side, you can use the
nlapiEditSubrecord('shippingaddress')
function to get the address subrecord. After making changes, don't forget to commit it.
To add a new billing or shipping address to a customer record, you need to load the customer, select a new line on the addressbook sublist (use defaultbilling
on a sublist if you want it to be the default), create createCurrentLineItemsSubrecord
, set values, commit the subrecord, commit the line, and save the record.
Here is an example of how to create a new address in Suitelet:
javascript
const createShipAddress = (customerId, addressObj) => {
let rec = record.load({
type: record.Type.CUSTOMER,
id: customerId,
isDynamic: true
});
rec.selectNewLine({
sublistId: 'addressbook'
});
rec.setCurrentSublistValue({
sublistId: 'addressbook',
fieldId: 'label',
value: addressObj.addressName
});
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
});
rec.commitLine({
sublistId: 'addressbook'
});
try{
var recId = rec.save();
log.debug({
title: 'Record created successfully',
details: 'Id: ' + recId
});
} catch (e){
log.error({
title: e.name,
details: e.message
});
}
}
To get the ID of the created address, you may need to create a customer Saved Search for the address subrecord. The address list uses the addressbook line's id, not the id of the address subrecord. You can get the id from the customer record and hardcode it to see if it fixes the problem, then figure out how to do the search or query.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/29/2025, 6:35 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845718801
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845681846
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838994622
Celigo AI
04/29/2025, 6:35 PM