I'm trying to set the value of the shipping addres...
# suitescript
l
I'm trying to set the value of the shipping address of an SO in a script but it doesn't allow me to save it without checking the Override box on the Address subrecord. Is that really the case?
b
what does the code look like
l
const beforeSubmit = (scriptContext) => {
const thisRecord = scriptContext.newRecord;
const customer = thisRecord.getValue({
fieldId: 'entity'
});
if(Number(customer) === 12345) {
const locationId = thisRecord.getValue({
fieldId: 'location'
});
if(locationId) {
const locAddress = search.lookupFields({
type: 'location',
id: locationId,
columns: [
'address.attention',
'address.addressee',
'address1',
'address2',
'address3',
'city',
'country',
'zip',
'state'
]
});
const shipAddress = thisRecord.getSubrecord({
fieldId: 'shippingaddress'
});
shipAddress.setValue({
fieldId: 'country',
value: locAddress['country']
})
shipAddress.setValue({
fieldId: 'zip',
value: locAddress['zip']
})
shipAddress.setValue({
fieldId: 'state',
value: locAddress['state']
})
shipAddress.setValue({
fieldId: 'city',
value: locAddress['city']
})
shipAddress.setValue({
fieldId: 'attention',
value: locAddress['address.attention']
})
shipAddress.setValue({
fieldId: 'addressee',
value: locAddress['address.addressee']
})
shipAddress.setValue({
fieldId: 'addr1',
value: locAddress['address1']
})
shipAddress.setValue({
fieldId: 'addr2',
value: locAddress['address2']
})
shipAddress.setValue({
fieldId: 'addr3',
value: locAddress['address3']
})
}
}
}