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
TilluTillu 

Java script is not working properly ? any help ?

On Opportunity   record ..i want to create a butoon  when we click that button the opportunity field ''stage"  value should need to be change to  ''6 – Closed Lost'. After it should open another pop up and need to display a Text in a Text field. i was strucked on stage field it self ? any help please.....


{!requireScript("/soap/ajax/26.0/connection.js")}
var Opportunity = new sforce.SObject("Opportunity");
Opportunity.StageName = '6 – Closed Lost';
sforce.connection.update([Opportunity]);
window.location.reload();
Naveen Rahul 3Naveen Rahul 3

Dear Tillu,

The below code will work,you have forgot the Where condition 

{!requireScript("/soap/ajax/26.0/connection.js")}
var Opportunity  = new sforce.SObject("Opportunity");
 
Opportunity.StageName = 'Closed Lost';
Opportunity.Id='{!Opportunity.Id}'; 
result  = sforce.connection.update([Opportunity]);
if (result[0].getBoolean("success")) {
    alert(result[0].id);
}
alert(result); 
window.location.reload();

 

You know Debug is our old friend