You need to sign in to do that
Don't have an account?
vcv
Issue with referencing a field from related custom object
Hi, I have the classic issue. There are three custom objects (Employees, Productivity, Salaries) which have lookup relationships to each other. I'm using the standard controller "Employees__c" and want to make a form where I access the field Level__c from Productivity__c and Grading__c from Salaries__c.
What's wrong with my __r usage? :)
What's wrong with my __r usage? :)
<apex:page standardController="Employees__c"> <apex:form id="formEmp" > <apex:pageBlock title="Link employees"> <apex:pageBlockSection columns="1"> <apex:inputField value="{!Employees__c.FirstName__c}"> </apex:inputField> <apex:inputField value="{!Employees__c.Productivity__r.Level__c}"> </apex:inputField> <apex:inputField value="{!Employees__c.Productivity__r.Level__c}"> </apex:inputField> <apex:inputField value="{!Employees__c.Salaries__r.Grading__c}"> </apex:inputField> </apex:pageBlockSection> <!-- buttons --> <apex:pageBlockButtons > <apex:commandButton id="Save" action="{!Save}" value="Save"/> <apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
You cannt able to save it direcly into the related object from your code
make changes as below
implement save logic in apex class
the code you proposed doesn't work.
This part works: This doesn't, I get "... apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.":