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
vikramkkvikramkk 

Open a custom visual forcepage based on field value

Hi

 

I created a custom button on opportunity standard page. When the button is clicked a custom visual force page is opened  based on some criteria. The content source for this is onclick javascript. Then, on clicking the button the java script code associated with button should evaluate a criteria-  which is -

 

the custom visual force page should be opened only when address field in account related to current opportunity is not empty otherwise a page with error message should be displayed."

 

Please let me know how this can be achieved.

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

sample code of the button would be like this...

 

 

{!REQUIRESCRIPT("soap/ajax/20.0/connection.js")}

{!REQUIRESCRIPT("soap/ajax/20.0/apex.js")}

if('{!Account.Phone}' != '' ) 

window.open('/apex/helloworld');

 

and about error message i dont think so that u can post an error message to the standard page through this action.. but you can give an alert in order to show the error message.

All Answers

kiranmutturukiranmutturu

sample code of the button would be like this...

 

 

{!REQUIRESCRIPT("soap/ajax/20.0/connection.js")}

{!REQUIRESCRIPT("soap/ajax/20.0/apex.js")}

if('{!Account.Phone}' != '' ) 

window.open('/apex/helloworld');

 

and about error message i dont think so that u can post an error message to the standard page through this action.. but you can give an alert in order to show the error message.

This was selected as the best answer
vikramkkvikramkk

This worked. Thanks a lot.