function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JerryJosephJerryJoseph 

copy field value from one object to another object

i wanna copy the value in a custom field in Opportunity to a custom field in the corresponding Account.

i did this successfully with a custom button in Opportunity an if i click the button the value gets copied. But i want this done for all the Opportunities. How can i do this? The code for the custom button is given below..

var acc = new sforce.SObject("Account");
var newRecords = [];
acc.id = "{!Opportunity.AccountId}";
acc.Test__c = "{!Opportunity.Test__c}";
if ("{!Opportunity.StageName}"=="Closed Won")
{
    newRecords.push(acc);
    result = sforce.connection.update(newRecords);
}
else
{
    alert("Sorry this opportunity is not Closed Won");
}

How do i loop through all the Opportunities? Using "For Each" or something like that..
devNut!devNut!
Using code, you'd have to query the opportunity records and process each one in a for loop.

Another option is to extract the opportunity fields (AccountId, Test__c) using the dataloader and perform an update operation on the Account object.
jbardetjbardet

I was wondering if it's possible to have a button with simple functionality while in the "edit all products" screen.

We have two fields there, Quoted Price and Sales Price. I'd like a button called "Use Quoted Price as Sales Price" and have it simply copy and paste the text from the Quoted Price into the Sales price of that line item, and it should do this for all line items at once.

Is this even possible (using Professional Edition)? If you don't have the time to explain, a simple yes or no helps me out incredibly as I can continue to search for the answer, or stop right now.

Thanks very much!!