• Hilary Henderson
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Operations Administrator
  • Access Development


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Is it possible to use a custom button to create a new record? I'd like to put the button on a custom object (Task Order__c) and have it create a new Opportunity, pulling information from the Task Order into the Opportunity fields. I would also like to be able to specify the record type of the new Opportunity. I have cobbled this together based on some examples I found of other buttons. Am I on the right track? Thanks in advance.

 

Here is what I am trying:

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newopportunity= new sforce.SObject("Opportunity");
newopportunity.Name = "my new opportunity";
newopportunity.Account="{!Task_Order__c.Account__c}";
newopportunity.StageName="Active";
newopportunity.CloseDate=new Date();
newopportunity.Student_Name__c="TBD";
var result = sforce.connection.create([newopportunity]);
window.location.reload();