Vernita
03/20/2024, 10:42 PM// If a new line was successfully selected
if (addressSublistLine !== -1) {
// Get the subrecord for the selected sublist line
var addressSubrecord = customerRecord.getCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
// Set the address details in the subrecord
addressSubrecord.setValue({
fieldId: 'country',
value: 'AU'
});
addressSubrecord.setValue({
fieldId: 'addr1',
value: address1
});
addressSubrecord.setValue({
fieldId: 'addr2',
value: address2
});
addressSubrecord.setValue({
fieldId: 'city',
value: city
});
addressSubrecord.setValue({
fieldId: 'zip',
value: postCode
});
addressSubrecord.setValue({
fieldId: 'state',
value: state
});
addressSubrecord.setValue({
fieldId: 'label',
value: 'Default Shipping'
});
//addressSubrecord.setCurrentSublistValue({
// sublistId: 'addressbook',
// fieldId: 'label',
// value: 'Shipping address'
// });
// Commit the sublist line
customerRecord.commitLine({
sublistId: 'addressbook'
});
// Get the line number of the newly created line
var lineCount = customerRecord.getLineCount({ sublistId: 'addressbook' });
var lastLine = lineCount - 1;
// Select the last line in the addressbook sublist
customerRecord.selectLine({
sublistId: 'addressbook',
line: lastLine
});
// Set the label for the current line of the addressbook sublist
customerRecord.setCurrentSublistValue({
sublistId: 'addressbook',
fieldId: 'label',
value: 'Shipping address'
});
log.debug('lastLine',lastLine)
// Commit the sublist line
customerRecord.commitLine({
sublistId: 'addressbook'
});
// Save the customer record
customerRecord.save();
The image shows what the script returns.
However, if you try to edit the address subrecord, it shows the State as blank
NetSuite have filed this as a defect. I suspect this is more likely an issue with the script. Can anyone see what is wrong in the script?battk
03/21/2024, 1:16 AMVernita
03/21/2024, 1:39 AMbattk
03/21/2024, 1:49 AMbattk
03/21/2024, 1:52 AMbattk
03/21/2024, 1:52 AMStefan Reeder
03/21/2024, 2:18 AMfunction getStates(countryCode) {
var filters = [
["inactive", "is", "F"]
];
if (countryCode) {
filters.push("AND")
filters.push(["country","anyof",countryCode])
}
var searchObject = search.create({
type: "state",
filters: filters,
columns:
[
search.createColumn({name: "id", label: "Id"}),
search.createColumn({
name: "fullname",
sort: search.Sort.ASC,
label: "Full Name"
}),
search.createColumn({name: "shortname", label: "Short Name"}),
search.createColumn({
name: "country",
sort: search.Sort.ASC,
label: "Country"
}),
search.createColumn({name: "inactive", label: "Inactive"})
]
});
return searchObject.run();
}
Stefan Reeder
03/21/2024, 2:18 AMStefan Reeder
03/21/2024, 2:18 AMVernita
03/21/2024, 7:29 AMVernita
03/21/2024, 7:31 AMVernita
03/21/2024, 7:31 AMVernita
03/21/2024, 7:38 AMbattk
03/21/2024, 8:23 AMbattk
03/21/2024, 8:24 AMVernita
03/21/2024, 10:32 AM