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
David ZhuDavid Zhu 

How to tell which action is invoked?

I have a custom object and I want to replace Delete, Edit, New, and View actions content source with VF page.
I want to use the same VF page but display differnt section for different action.

Is there a way to tell which action is invoked in Apex?

thanks,
David
Adam OlshanskyAdam Olshansky
Is there a reason why you'd like to display different sections of the same page instead of just displaying different pages?  Your best bet would be to handle this logic in the controller extension for the page.  If the ID of the object is null when the page loads, you'll know that it is the New action, if it's populated, it's the Edit action.  Since you'll probably want to provide Input fields for New/Edit and Output fields for View, I think it would make more sense to have different pages and then just override the corresponding actions within setup.
AshlekhAshlekh
Hi,

In that case you need to use if else conditons or rendered part on UI. On UI you can put the condtion on section for rendered in which condtion.

-Thanks
Ashlekh Gea
David ZhuDavid Zhu

Thanks Guys for your quick feedbacks.
Actually, I have already implemented the actions with different VF pages. In my opinion, it would be perfect for maintainance purpose if all of pages can be merged in one page with displaying different section for different action.

Specifically, I am looking for methods similar to "action.isnew", "action.isedit". 

For now, it seems idea combining Adam and Shlekh's suggestion is way to go.