Tyson Freeze
02/22/2025, 11:24 PMCeligo AI
02/22/2025, 11:24 PMAI generated answer (using internal Slack threads):To source a Suitelet select field with the addresses of a specific customer in code, you can use SuiteScript to create a custom field and populate it with the customer's addresses. Here's a step-by-step guide: 1. First, create a custom field in your Suitelet form using the
Form.addField
method. This will create a dropdown list where you can add the customer's addresses.
javascript
var addressField = form.addField({
id: 'custpage_address',
label: 'Address',
type: serverWidget.FieldType.SELECT
});
2. Next, load the customer record and get the count of addresses in the addressbook sublist.
javascript
var customer = record.load({
type: record.Type.CUSTOMER,
id: customerId
});
var addressCount = customer.getLineCount({sublistId: 'addressbook'});
3. Loop through the addressbook sublist and for each line, get the address subrecord. From the subrecord, get the address details and concatenate them into a single string.
javascript
for (var i = 0; i < addressCount; i++) {
var addressSubrecord = customer.getSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'address',
line: i
});
var addr1 = addressSubrecord.getValue({fieldId: 'addr1'});
var addr2 = addressSubrecord.getValue({fieldId: 'addr2'});
var city = addressSubrecord.getValue({fieldId: 'city'});
var state = addressSubrecord.getValue({fieldId: 'state'});
var zip = addressSubrecord.getValue({fieldId: 'zip'});
var fullAddress = addr1 + ', ' + addr2 + ', ' + city + ', ' + state + ', ' + zip;
}
4. Add each address as an option in the custom field using the Field.addSelectOption
method.
javascript
addressField.addSelectOption({
value: i,
text: fullAddress
});
This will create a dropdown list in your Suitelet form populated with the customer's addresses.
******
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
02/22/2025, 11:24 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.869197309
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851816416
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840480685
Celigo AI
02/22/2025, 11:24 PM