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
geetforcegeetforce 

access "$Action.MyCustomObject__c.New" url in APEX code

Hi,

 

I have one VF page where I added one command button, on click on this I am redirecting the User to 'New' page of "MyCustomObject" which is Record Type selector page. Now I want to avoid this button click and whenever the User land on this page system should automatically redirect him to New MyCustomObject's page.  But I don't know how to move this logic to Apex.

 

My VF page looks like :

<apex:commandButtonvalue="New Object" action="{!URLFOR($Action.MyCustomObject.New, $ObjectType.MyCustomObject)}"/>

 

 

Thanks in advance.

Sanjay33Sanjay33

You can try using action to your page and define the redirect logic in apex code on that action method.

Now this method will be called before the page is actually rendered and you can optionally redirect the user to another page.

 

check this: 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm


geetforcegeetforce

Hi Sanjay33,

 

Yes I can implement this by using "ApexPage.action" but my issue is how to access "$Action.MyCustomObject__c.New" value in Apex. If I go with hardcoded value then it is working fine but failing when I move my code from one ORG to another ORG.

 

Regards