function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
V100V100 

Using a visual force page to pass an ID

I  am using a visual force page to replace a related list with the code below.

When the New Team Contact is clicked I want it to prefil the related ID field from the link.

 

Is this possible and if so can someone help me create this.

<apex:page standardcontroller="ADP__c" showHeader="false">


<apex:relatedList list="ADP_Account_Team__r" title="" />


    <apex:pageBlock mode="edit">
    
      <apex:outputLink target="_top" value="{!URLFOR($Action.ADP_Account_Team__c.New)}" style="font-weight: bold;">New Team Contact</apex:outputLink>

        <apex:pageBlockTable value="{!ADP__c.ADP_Account_Team__r}" var="thisService">
        
  <apex:column >
            <apex:outputLink value="{!URLFOR($Action.ADP_Account_Team__c.Edit,thisService.id)}" style="font-weight: bold;">Edit</apex:outputLink> |&nbsp; 
             <apex:outputLink value="{!URLFOR($Action.ADP_Account_Team__c.Delete,thisService.id,[retURL=URLFOR($Action.ADP__c.View, ADP__c.Id)])}" onclick="return window.confirm('Are you sure?');" style="font-weight: bold;">Del</apex:outputLink>
        </apex:column>
        
            <apex:column value="{!thisService.Role__c}"/>
            <apex:column value="{!thisService.User__c}"/>
            <apex:column value="{!thisService.Telephone__c}"/>
            <apex:column value="{!thisService.Email__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

</apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd

ADP__c, Account Development Plan perhaps? Funny as I have the exact same object name.

 

Ok, back on topic. You sould be able to pass the Id of the realted object to the value of the URL. For example if you are created a contact from and account the URL will look like this:

 

https://cs1.salesforce.com/003/e?accid=0015000000R8Tpn

 

Create a new ADP_Account_Team__c record throught the normal UI by clicking the New button on the related list of the ADP__c. Inpect the URL and see what URL parameter you need to set. I'm guessing it will be something like this:

 

value="{!URLFOR($Action.ADP_Account_Team__c.New)}?adp__c={!ADP__c.Id}"

All Answers

Shailesh DeshpandeShailesh Deshpande

you will need to use <apex:param> tag for that purpose.

TehNrdTehNrd

ADP__c, Account Development Plan perhaps? Funny as I have the exact same object name.

 

Ok, back on topic. You sould be able to pass the Id of the realted object to the value of the URL. For example if you are created a contact from and account the URL will look like this:

 

https://cs1.salesforce.com/003/e?accid=0015000000R8Tpn

 

Create a new ADP_Account_Team__c record throught the normal UI by clicking the New button on the related list of the ADP__c. Inpect the URL and see what URL parameter you need to set. I'm guessing it will be something like this:

 

value="{!URLFOR($Action.ADP_Account_Team__c.New)}?adp__c={!ADP__c.Id}"
This was selected as the best answer