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
scottious888scottious888 

Can't pick up related ID in a new record

I have two objects. Preplanning__c and Touch__c. Preplanning belongs to Touch. I want to create a new Preplanning record from the Touch record and have the Touch ID automatically inserted in the form. When I try to use my own custom Visualforce form this doesn't work.

 

Here's my visualforce form ...

 

<apex:page standardController="Preplanning__c" id="thePage"> <apex:form > <apex:pageBlock id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="1"> <apex:outputField value="{!Preplanning__c.Touch__c}" /> <apex:inputField value="{!Preplanning__c.Who_is_the_carrier__c}" /> <apex:inputField value="{!Preplanning__c.Is_it_bundled_or_unbundled__c}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

This works fine when using this form for editing the record, just not inserting. And I can see that the value is passed on the URL?? I don't get it, I figure I must be missing something basic as this should be straight forward.

 

Thanks.

Ron HessRon Hess

You will need to write a controller extension to set the Touch__c value given a parameter on the query string.

what value is passed on the query string ? 'id' ?

if so, then the ID is for the PrePlanning object not the touch object.

you must have another parameter that specifies which Touch__c object this new preplanning object will belong to.  That is the parameter you will use in the extension to populate the field in the new preplanning object.

 

 

can you show what the URL looks like when this form comes up ( new record) 

Message Edited by Ron Hess on 02-04-2009 08:32 PM
scottious888scottious888

Here's the URL

 

https://c.na6.visual.force.com/apex/Preplanning_New?CF00N80000002kuwj=TCH-00004&CF00N80000002kuwj_lkid=a008000000C9Bj6&scontrolCaching=1&retURL=%2Fa008000000C9Bj6&sfdc.override=1

 

 The variable CF00N80000002kuwj is the one I need. I did create a temporary work around by using javascript to populate the ID field on page load, but this is hack and would love to see how it's done properly. Thanks!