hi
we are trying to set a custom address as a ship to address on a RMA record in beforeSubmit event
(I have attached the script below as well), the issue is the address is not being updated to the parent object (in this case the Sales order). Can you please help
function beforeSubmit(scriptContext) {
var logObjectInput = errorHandler.Start(FILE_CONSTANT.SCRIPT_PARAM.LOG_FLAG,FILE_CONSTANT.SCRIPT_PARAM.FRICEW_ID, FILE_CONSTANT.SCRIPT_PARAM.EXECUTION_ID,FILE_CONSTANT.SCRIPT_PARAM.PARENT_DEPLOYMENT_ID, null, true);
try
{
log.debug('start of beforeSubmit script','************** Start ******************');
if(scriptContext.type =='create'){
var retAuthRecord = scriptContext.newRecord;
var shipAddr = retAuthRecord.getSubrecord('shippingaddress');
shipAddr.setValue({fieldId : 'override', value: false});
shipAddr.setValue({fieldId : 'attention', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stattn'})});
shipAddr.setValue({fieldId : 'country', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stcountry'})});
shipAddr.setValue({fieldId : 'state', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_ststate'})});
shipAddr.setValue({fieldId : 'addressee', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stacct'})});
shipAddr.setValue({fieldId : 'addrphone', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stphone'})});
shipAddr.setValue({fieldId : 'addr1', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_staddr1'})});
shipAddr.setValue({fieldId : 'addr2',value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_staddr2'})});
shipAddr.setValue({fieldId : 'addr3',value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_staddr3'})});
shipAddr.setValue({fieldId : 'city', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stcity'})});
shipAddr.setValue({fieldId : 'zip', value: retAuthRecord.getValue({fieldId: 'custbody_kfx_sfdc_stzipcode'})});
shipAddr.setValue({fieldId : 'Override', value:true });
//shipAddr.commit();
//retAuthRecord.save();
}
}
catch(e)
{
log.debug('Error','Error::'+e);
errorHandler.Error(logObjectInput, 'beforeSubmit', 'Return Authorization', null, e, null, null, true);
throw e;
}
}