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
jojoforcejojoforce 

How to call the "Create New Record" page from a VisualForce button?

I have a visual forcepage that is two column table which list the Accounts on the first column, and the Actions on the next column. Basically, on the Action column I want to have a "New Entry " link or button that will take the user to the "New Record Entry Page" for a custom object. Any insight or suggestion as to how to make this work is greatly appreciated!

 

            <apex:column headervalue="Action">
                    <b><u><a href="(take me to the create new record page)">Create New Entry</a></u></b>
            </apex:column>

 

jwetzlerjwetzler

  <a href="{!URLFOR($Action.MyObject__c.new)}">New Record</a>

jojoforcejojoforce

Thanks I tried that and it's opening up the new entry form but it's  not populating the Account ID on that form. The custom object has a lookup relationship with the Account object. If I click the the "New" link the, account associated to the action should be prepopulated on the entry form. Any ideas?

RArunrajRArunraj

Hi,

 

Please use the below code for auto populating the Account name in the lookup field of the custom object.

 

<apex:page tabStyle="Account" standardController="Account" recordSetVar="at">    

<apex:pageBlock >        

<apex:form >            

<apex:pageBlockTable value="{!at}" var="act">                

<apex:column headerValue="AccountName">{!act.name}</apex:column>                                

<apex:column headerValue="Action">                    

<apex:outputlink

value="/a0P/e?CF00N90000002bPzT={!act.name}&CF00N90000002bPzT_lkid={!act.id}">CreateNew Entry</apex:outputlink>              

</apex:column>                            

</apex:pageBlockTable>        

</apex:form>    

</apex:pageBlock>

</apex:page>

 

 

a0P --> First 3 digit of your custom object record

CF00N90000002bPzT --> To get this id --> customize --> create objects  --> click on your custom object --> go to the account lookup field and click it --->In the URL you will be able to see the id starts with 00N --> copy that id and replace after CF in the URL

 

Thanks,

R. Arunraj

RArunrajRArunraj

Hi,

 

Do you able to auto populate the Account name in the newly created record using the above code.

 

Thanks,

R. Arunraj