Posts

Showing posts with the label custom Button

Custom button on Opportunity to clone opportunity with its related List (object)

Create a new Detail Page Button on the Opportunity object. Set Behavior to Execute JavaScript and Content Source to OnClick JavaScript Paste the Below snippet of code in the window {!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}  {!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}  var retStr;  retStr = sforce.apex.execute(" CloneOpportunitywithRelatedObject "," cloneOpportunity ",  {oppId:"{!Opportunity.Id}"});  location.replace('/' + retStr);   Create a new Apex class and paste the below snippet of code global class  CloneOpportunitywithRelatedObject  {     webservice static Id  cloneOpportunity (Id oppId) //  pass parameters     {         List < Related_Object__C > relatedList = new List < Related_Object__C > ();   // query all the fields you need...

Custom Button to take Ownership for Case Record

Create a new Detail Button on the Case object. Set Behavior to Execute JavaScript and Content Source to OnClick JavaScript Paste the Below snippet of code in the window  {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}  var caseObj = new sforce.SObject("Case");  caseObj.Id = '{!Case.Id}';  caseObj.OwnerId = '{!$User.Id}';  var result = sforce.connection.update([caseObj]);  if (result[0].success=='false') {  alert(result[0].errors.message);  }  else {  href= "https://cs16.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/{!Case.Id}" ;  // return to console document.location.reload(true)               // Refresh the Tab } Note : Change the return URL    to Current URL. Enjoy Coding !!

Custom Button for Cloning Opportunity without items.

Image
Hi Developers !!. This post is regarding the   Custom Button   on Opportunity Object which  will help us to create clone opportunities without Line items with default values. Please follow the below steps: 1. Go to setup. 2. Create new custom button for Opportunity object. 3. Give the Label for button. 4. Set behavior as 'Execute JavaScript' and Content Source as 'OnClick JavaScript' . Paste the below snippet of code in your window. try { { !REQUIRESCRIPT("/soap/ajax/14.0/connection.js") } // Below query will helps you to copy all the fields from your opportunity. var result = sforce.connection.query("Select opp.Type, opp.StageName, opp.Amount, opp.AccountId,opp. CloseDate,opp.ForecastCategoryName From Opportunity opp WHERE opp.Id = '{!Oppor...