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

  • What did you try ? Can you share your code ? – SF_user Jun 8 '15 at 8: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 8 '15 at 8: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 8 '15 at 9: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 8 '15 at 9:03
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; 
}

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.