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
Sylvain@RibbonFishSylvain@RibbonFish 

Customize New button depending of the current view

Hi everyone,

I have modified the Opportunity object and I have created 2 views:

ViewTypeA: return me all the Opportunity of a certain customType__c = "ExampleA"

ViewTypeB: return me all the Opportunity of a certain customType__c = "ExampleB"

Now when I'm on the view I can still access to the button "New Opportunity". When I click on the button I would like to display 2 types of New Opportunity windows depending of the view where the user is from.

Now I have already override the new behavior.

I want to know if it's possible to know which view was selected by using before clicking on new?

Thanks

Sylvain

 

Best Answer chosen by Admin (Salesforce Developers) 
puneet28puneet28

Hi Sylvain@Ribbon,

 

You can use the method defined here:

http://www.codespokes.com/2012/02/i-need-to-get-id-of-any-list-view-of.html

 

It will give you the list view id and then you can compare with the Ids of your list views.

This will be checking the Id values against harcoded ids.

 

If you want to check using name, you will have to use the method defined here:

http://boards.developerforce.com/t5/Visualforce-Development/Query-for-list-view-Id-s-and-names/td-p/174398

 

Also make sure that you add that custom button to Opportunities List View Search Layout

To do this go to Setup, click Customize, select Opportunities, and click Search Layouts.

Click Edit next to the Opportunities List View.

All Answers

puneet28puneet28

Hi Sylvain@Ribbon,

 

You can use the method defined here:

http://www.codespokes.com/2012/02/i-need-to-get-id-of-any-list-view-of.html

 

It will give you the list view id and then you can compare with the Ids of your list views.

This will be checking the Id values against harcoded ids.

 

If you want to check using name, you will have to use the method defined here:

http://boards.developerforce.com/t5/Visualforce-Development/Query-for-list-view-Id-s-and-names/td-p/174398

 

Also make sure that you add that custom button to Opportunities List View Search Layout

To do this go to Setup, click Customize, select Opportunities, and click Search Layouts.

Click Edit next to the Opportunities List View.

This was selected as the best answer
Jerun JoseJerun Jose
Agree with Puneet's suggestion. You might need a custom button for this purpose. Although I am wondering how to pass information about which list view was selected initially. AFAIK, the button override does not allow us to pass parameters to the page.