You need to sign in to do that
Don't have an account?
acrozier
Creating a custom edit page
I have two Objects with a Master-Detail relationship. I have created a custom edit page for the child object but the page only displays the line item that you click edit for and not the other child objects related to the parent. How can I create an SOQL statement to pull in all child objects related to parent to be edited. Code is below.
Parent= Job__c
Child= AIIncentive__c
VisualForce page (Second DataTable is only there to test SOQL statements)
<apex:page standardController="AIIncentive__c" extensions="Incent"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!AIIncentive__c}" var="incent"> <apex:column headerValue="QTY"> <apex:inputField value="{!incent.QTY__c}"/> </apex:column> <apex:column headerValue="Description"> <apex:inputField value="{!incent.Description__c}"/> </apex:column> <apex:column headerValue="Honoraria__c"> <apex:inputField value="{!incent.Honoraria__c}"/> </apex:column> <apex:column headerValue="Job #"> <apex:outputField Value="{!incent.Job__c}"/> </apex:column> </apex:PageBlockTable> <apex:PageBlockTable value="{!Incents}" var="I"> <apex:column > <apex:OutputField value="{!I.QTY__c}"/> </apex:column> </apex:PageBlockTable> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlock> </apex:form> </apex:page>
Extension
public with sharing class Incent { public list<AIIncentive__c> Incents {get; set;} public list<job__c> job {get; set;} public id jobid; public string r {get; set;} public Incent(ApexPages.StandardController controller) { jobid = apexpages.currentpage().getParameters().get('id'); r = [Select Name, id FROM Job__c WHERE id = :jobid limit 1]; Incents = [Select QTY__c, Description__c, Honoraria__c, Job__c From AIIncentive__c where Job__c = :r]; } }
I think your object types are a little confused. You are using a standard controller of AIIncentive__c, but then treating the id as a job in your extension controller.
I think it should be more like:
All Answers
I think your object types are a little confused. You are using a standard controller of AIIncentive__c, but then treating the id as a job in your extension controller.
I think it should be more like:
I could kiss you.
Is there a function to call to Save and add new for the aforementioned Visualforce page?
You'll have to code those up yourself. There is a save on the standard controller, but that will only save the record that you clicked on to get to this page (i.e. the record id in the URL).
Do you just want to add another row, or do you want to be able to remove existing rows etc?
Here's a blog post I wrote a while ago that should give you some pointers, although its not a direct match for what you are trying to do:
http://bobbuzzard.blogspot.com/2011/07/managing-list-of-new-records-in.html