Here is the scenario,
Let’s consider, I have created a custom button called “Submit Data” in Opportunity object and I placed this button in detail page of the opportunity layout.
When if I clicked “Submit Data” button from the Console app, then “Page1” (VF Page) should open, else “Page2” (VF Page) should get opened.
Ensure the followings, before place the below code in a button,
1. Behaviour – Execute JavaScript
2. Content Source – OnClick JavaScript
Let’s consider, I have created a custom button called “Submit Data” in Opportunity object and I placed this button in detail page of the opportunity layout.
When if I clicked “Submit Data” button from the Console app, then “Page1” (VF Page) should open, else “Page2” (VF Page) should get opened.
Ensure the followings, before place the below code in a button,
1. Behaviour – Execute JavaScript
2. Content Source – OnClick JavaScript
- {!REQUIRESCRIPT("/support/console/28.0/integration.js")}
- if(sforce.console.isInConsole())
- {
- srcUp('/apex/Page1?isdtp=vw');
- }
- else
- {
- window.open('/apex/Page2');
- }
Reference: