You need to sign in to do that
Don't have an account?
Custom Link to Custom Object Visual Force Page
I have made a custom link to a visual force page that i want to take the form of a custom object that I created. The custom object has a master relationship with accounts. When I click on the link within accounts, I can only access the account and pull up the related list of the custom object. I want to be able to edit or add a record to the object. What am I missing? Here is what I have so far, as you can see I am new to this!
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="Par Reports">
<apex:pageblocktable value="{!account.par_reports__r}" var="p">
<apex:column value="{!p.As_of_Date__c}"/>
</apex:pageblocktable>
<apex:pageblockbuttons >
<apex:commandButton value="Edit" action="{!Edit}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
You can add a button to the page block table and give the action as
<apex:commandbutton value = "New" action="{!URLFOR($Action.yourobjectAPIName.New)}"/>
For Edit you can provide an extra column and give the
<apex:commandLink value = "Edit" action="{!URLFOR($Action.yourobjectAPIName.Edit)}"/>
Thanks srini,
The new action works great. I am having trouble adding the edit action into the table. That I have already created. How do I add the commandlink as a variable in my table?
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="Par Reports">
<apex:pageblocktable value="{!account.par_reports__r}" var="c">
<apex:column value="{!c.As_of_Date__c}"/>
<apex:commandlink value="Edit" action="{!URLFOR($Action.par_report__c.edit)}">
</apex:pageblocktable>
<apex:pageblockbuttons >
<apex:commandButton value="New" action="{!URLFOR($Action.par_report__c.new)}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
<apex:pageblocktable value="{!account.par_reports__r}" var="c">
<apex:column>
<apex:commandlink action="{!URLFOR($Action.par_report__c.edit)}" value="Edit">
<apex:param name="id" value="{!c.id}"/>
</apex:commandLink>
</apex:column>
</apex:pageblocktable>
I have two issues:
With the new button, the form loads, but the account lookup is now blank, and it would require the user to lookup the account. I want it to appear as if I clicked the new button within account where the account is already attached since it is a master relationship.
Secondly, the edit fields do appear in a new column, but when clicked I get the "Invalid parameter for function URLFOR" error:
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="Par Reports">
<apex:pageblocktable value="{!account.par_reports__r}" var="c">
<apex:column >
<apex:commandlink action="{!URLFOR($Action.par_report__c.edit)}" value="Edit">
<apex:param name="id" value="{c.id}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!c.As_of_Date__c}"/>
</apex:pageblocktable>
<apex:pageblockbuttons >
<apex:commandButton value="New" action="{!URLFOR($Action.par_report__c.new)}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>
Fixed the Edit buttons by changing to: <apex:commandlink action="{!URLFOR($Action.par_report__c.edit,c.id)}" value="Edit">
Sill trying to figure out the New button.