0

I want to query for opportunity from Quote page i.e. Detail page button of Quote on click of javascipt of that button..

alert({!Opportunity.StageName}); 
if('{!Opportunity.StageName}' =='F0') { 
alert('Can not Create Multiple Quote as Opportunity is moved to F0.'); 
} 

This is what I am trying to do..on Detail page button of Quote but this alert is showing null value

Vamsi Krishna Gosu
  • 10,464
  • 5
  • 32
  • 49
  • What did you try ? Can you share your code ? – SF_user Jun 08 '15 at 08:55
  • alert({!Opportunity.StageName}); if('{!Opportunity.StageName}' =='F0') { alert('Can not Create Multiple Quote as Opportunity is moved to F0.'); }

    This is what I am trying to do..on Detail page button of Quote but this alert is showing null value...

    – Nikhil Boob Jun 08 '15 at 08:56
  • 1
    If you add javaScript you should always check your browser's JavaScript console. See e.g. How do I start to debug my own Visualforce/JavaScript?. Your alert is missing some quotes. – Keith C Jun 08 '15 at 09:01
  • The thing is that opportunity is not getting queried and hence it is showing null value. I have done same thing from list button on opportunity page and I am getting proper value, please suggest how can I perform this from Quote Detail page button? – Nikhil Boob Jun 08 '15 at 09:03

1 Answers1

0

In Javascript

 // Query the Quote  records based on QuoteId 
 var quoteResult =sforce.connection.query("Select
 Id,Discount,OpportunityId,Opportunity.StageName From Quote where
 Id='{!Quote.Id}'");

 // Getting the Opportunity StageName from Query 
 var quoteRecords = quoteResult.getArray("records"); 
 for (var i=0; i< quoteRecords.length; i++) 
 { 
   var quoteRecord = quoteRecords[i]; 
   opportunityStageName= quoteRecord.Opportunity.StageName; 
}
nagarjuna
  • 317
  • 1
  • 6
  • 14