Hi
I am trying to create an address subrecord using a map reduce script.
Most of it works fine other than:
- It is not possible to set the state field
The relevant lines in the script are:
var leadId = inputData.id
var address1 = inputData.values['custentity_shipping_address_1']
var address2 = inputData.values['custentity_shipping_address_2']
var city = inputData.values['custentity_shipping_address_city']
var state = inputData.values['custentity_shipping_address_state'].value
var postCode = inputData.values['custentity_shipping_address_postcode']
Based on the debug log, this is returning the internal id of the state.
However, it appears as:
478 River Road
Sydney 402(this being the internal id of the State) 2011
Australia
The actual 'State' field in the address pop up remains blank.
I have tried changing the state variable to:
var state = inputData.values['custentity_shipping_address_state'].text
This gives me the following result:
Why are none of these variations on the script populating the state field?
The script lines setting the fields:
// 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: 'state',
value: state
});
addressSubrecord.setValue({
fieldId: 'zip',
value: postCode
});
// Commit the sublist line
customerRecord.commitLine({
sublistId: 'addressbook'
});
// Save the customer record
customerRecord.save();
Thanks