+ Start a Discussion
DoondiDoondi 

Prepopulating Field Values on Related list

Hi, I wanted to know how I can prepopulate the Lookup values.
There are two custom objects (school__c and student__c) having master detail relationship to Opportunities. 
This is my button code:
<button class="slds-button slds-button_neutral">
     <apex:outputLink 
                  value="!URLFOR($Action.Opportunity.New,null)}">
                    Add
     </apex:outputLink>
</button>
When I click on add, by default I am getting only School__c as prepopulated,
I want student__c also to be pre populated. 
 
Raj VakatiRaj Vakati
{!URLFOR(target, id, [inputs], [no override])}

 
{!URLFOR( $Action.Child_Object_Name__c.New , null, [saveURL=Parent_Object_Name__c.Link, retURL=Parent_Object_Name__c.Link, CF00NE0000002aLV0_lkid=Parent_Object_Name__c.Id , CF00NE0000002aLV0=Parent_Object_Name__c.Name])}

Refert this link

https://www.topalovich.com/2012/09/create-a-custom-new-button-on-a-related-list-to-return-to-the-parent-record-after-clicking-save/
DoondiDoondi
@Raj 
Thanks for quick response, 
At this moment, I don't want to Return to parent record after click on save.(this is not my requirement)
All I wanted is Prepopulate the values while creating a Opportunity
Below are some of the facts I forgt to tell in beginning.
> This button is there on School__c object(in Related List)
>If I click on Add button, School__c.Name will be prepopulated, 
But
> I want Student__c.Name also to be prepopulated.

As you said I tried the code
<apex:outputLink value="{!URLFOR( $Action.Opportunity.New , null, [saveURL=Student__c.Link,
 retURL=Student__c.Link, 
CFa023B000001l1XM=Student__c.Id , CFa023B000001o38E=Student__c.Name])}">
Add
</apex:outputLink>

This is the error I am getting 
Invalid field Link for SObject Student__c