I have two account lookup fields in a custom object, Billing Account and Shipping Account. On selection of Billing Account, I want the Shipping Account to be auto populated if the checkbox field ‘Same as Above’ is set to true.
I have a snippet built on the mobile page where I could get all address information autopopulated from Billing Account to custom fields (such as street, city, state, zip) on checking ‘same as above’, but I wasn’t able to get Shipping Account lookup field autopopulated from Billing Account.
How can I get the Shipping Account field autopopulated too?
Here is my code:
skuid.$(document).ready(function() { setTimeout(initSignature, 500);
returnsModel = skuid.model.getModel(‘FormData’);
FormDatafirstrow = returnsModel.getFirstRow();
calculatedDaysReturned(FormDatafirstrow.Date_Received__c);
sameAsAbove(FormDatafirstrow.Same_As_Above__c);
attachmentsModel = skuid.model.getModel(‘Attachments’);
AuthProdReturnRecType = skuid.model.getModel(‘RecordType’).getFirstRow().Id;
FormLineItemModel = skuid.model.getModel(‘FormLineItemData’);
});
function sameAsAbove(value){
// console.log('SAME AS ABOVE = '+value);
// console.log('Accountvalue = '+Accountvalue);
if(value === true && Accountvalue !== undefined){
var Account = skuid.model.getModel(‘Account’);
var ANcondition = Account.getConditionByName(‘Id’);
Account.setCondition(ANcondition,Accountvalue);
var AccountRow = Account.data[0];
//console.log('Account = '+Account);
Account.updateData(function(){
var aCount = Account.getFirstRow().BillingCountry;
returnsModel.updateRow(FormDatafirstrow, {Street_Address__c : Account.getFirstRow().BillingStreet,
City__c : Account.getFirstRow().BillingCity,
State_Province__c : Account.getFirstRow().BillingState,
Zip_Postal_Code__c : Account.getFirstRow().BillingPostalCode,
Country__c : aCount,
///Shipping_Account__c : Account.getFirstRow().Name + ’ ‘+Account.getFirstRow().BillingCity+’ - '+ Account.getFirstRow().Address_Number__c
//Shipping_Account__c : Account.getFirstRow().Id
});
});
}
Question
auto populate lookup field from another lookup field

Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.