0

This is loosely related to a recent question: Standard Button CODE Available?

Does anyone know of any examples/tutorials on creating a custom button which will set values into the PARENT record of the record/object that the button is clicked from?

Example: Opportunity has a Custom Object called Company Form. When Credit Card data is submitted via a Company Form and approved by various parties, they'd like a button to copy the CCard data into similarly named fields on the Parent (Opportunity).

So CreditCard_Name__c would be copied to the Opportunity's CCard_Name__c field as an example.

1

You can use a custom JS button and it would look something like this-

{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}

var connection = sforce.connection;

var oppty = "{!Company_forms__c.OpportunityId__c}";

if (oppty  != "")
{
    var opp = new sforce.SObject("Opportunity");
    opp.Id = oppty ;
    opp.CCard_Name__c = "{!Company_forms__c.CreditCard_Name__c}";

    connection.update([opp]);
    alert("Done.");
}
else
{
    alert("There is no Opportunity to update.");
}

Here is a good reference: http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax_more_samples.htm

|improve this answer|||||
0

Is there really a need for a button? You could accomplish this with workflow:

  1. Create a WF with rule, Company Form -> Status = "Approved"
  2. Create Field Updates with Cross Object WF that would copy these values from the Company Form to the Account
|improve this answer|||||

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.