My requirement is If Opportunity Stage value is 'CLose Lost' then a visual page will call and dynamically display the competitor, who gain the opportunity.

I am trying with below code, but it is not working .

?Can you please help me.


<apex:page standardController="opportunity" >
<script src="/soap/ajax/22.0/connection.js"></script>
<script src="/soap/ajax/22.0/apex.js"></script>
var arrId = '{!$CurrentPage.parameters.id}';
var queryresult = sforce.connection.query("Select StageName from Opportunity where id='"+arrId+"'");
var records = queryresult.getArray("records");
if(records[0].StageName=='Closed Lost')
window.open('/apex/searchOpp?id='+arrId ,'lookup','width=800,height=480,scrollbars=yes,left=200,top=100');


Hello Opportunity

  • 1
    What error are you getting? I just tested with your code and it seems to work perfectly fine, I just ran it from my JS console and it works okay, try adding in a few console.log() and display the text to the JS console. If you paste that and or a screenshot I should be able to help more. – Tim May 13 '15 at 11:59

I placed inline visual force page at wrong location.

| improve this answer | |

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.