0

Created a button with Execute JavaScript and OnClick JavaScript

var records = {!GETRECORDIDS($ObjectType.Order__c)}; 
var updateRecords = [];
if (records[0] == null) {
    alert("Please select at least one record to update.");
}
else { 
for (var a=0; a<records.length; a++) { 
var update_Account= new sforce.SObject("Order__c"); 
update_Order.Id = records[a]; 
update_Order.Mobile__c = Account.HomePhone__c; 
updateRecords.push(update_Order);
}
result = sforce.connection.update(updateRecords); 
parent.location.href = url;
}

I am not able to get copy the value in Mobile__c value to HomePhone

4
  • Any reason you cannot just use a workflow rule to do this? Does it require manual intervention?
    – Eric
    Nov 25 '16 at 4:39
  • Requirement of client is to make button on the object detail page
    – Ana
    Nov 25 '16 at 6:33
  • Just because it is a requirement given to you does not mean you should not present better options. Of course you would have to know why the requirement was made.
    – Eric
    Nov 25 '16 at 6:35
  • don't you need to define update_Order before assigning the id and mobile number to it?
    – Samir
    Nov 25 '16 at 6:55
0

Can you try this?I think you declared update_Account and used update_order

var records = {!GETRECORDIDS($ObjectType.Order__c)}; 
var updateRecords = [];
if (records[0] == null) {
    alert("Please select at least one record to update.");
}
else { 
    for (var a=0; a<records.length; a++) { 
    var update_Order= new sforce.SObject("Order__c"); 
    update_Order.Id = records[a]; 
    update_Order.Mobile__c = Account.HomePhone__c; 
    updateRecords.push(update_Order);
}

result = sforce.connection.update(updateRecords); 
parent.location.href = url;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.