You need to sign in to do that
Don't have an account?
MohanaGopal
Accessing Parent Fields from Related list Visual force page
Hi..
I have create one custom list button in my custom object (A) as VF page.. This object is related to master detail look up to another custom object (B)....
That is A is child B is Parent...
When I click my custom list button from related list of Parent object (B) I have to access parent object fields...
How is it possible...
I try following code for passing parent id to VF page in onclick of java script for calling this VF page.. It doesnt work properly...
That is parent id goes blank to the url
window.location.href = '/apex/myvfpagename?id={!A__c.B__c}';
Any one give some sample code for accessing parent fields or passing parent id to VF page....
If you are using master detail lookup, you will get the parent record id in the child itself right?
with that record id you can easily fetch the values.
If you want more clarification just mention the objects names and then how you are giving the relationship between those two objects.
<apex:form >
<apex:pageBlock title="Calculated Measure Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!save}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:inputField id="CurrentProject" value="{!Calculated_Measures__c.Project__c}"/>
</apex:pageBlockSection>
Hi,,
I have override child new button as VF page, When I click new button in Parent Related list I need to didplay parent name in corresponding field in Child page.. I have to fetch values based on the parent id from another object.. But my case Parent Id is null .. Can u send sample code for getting parent id..
My code is
<apex:pageBlockSection title="Information" id="info">
<apex:inputField id="CurrentProject" value="{!Calculated_Measures__c.Project__c}"/>
</apex:pageBlockSection>
Any one send sample code for resolve my problem..
Does anyone have an answer to this? I've got the exact same issue. Thanks.
I just came across very similar requirement as MohanaGopal.
What I've done might be a bit handy and specific but at least I can achieve my goal: having parent Id so that I can do other things in my visualforce page.
What I did is to use JavaScript to do some parsing for the custom button in child object. Details as below
{!REQUIRESCRIPT('/soap/ajax/20.0/connection.js')}
{!REQUIRESCRIPT('/soap/ajax/20.0/apex.js')}
var currentLocation = location.href;
var lastSlashIndex = currentLocation.lastIndexOf("/");
var parentId = currentLocation.substring(lastSlashIndex + 1, currentLocation.length);
location.href= '/apex/page_SetupContainerInfo?parentId=' + parentId;
Hope that help.