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
Jack KlausJack Klaus 

Cross Object Create/Update via Visualforce Page

Okay.  Over four days trying to solve this and I officially have no idea what I am doing...

Background:
New to SF (About two weeks) (I Appologize in Advance)
Professional Edition (Think this is a big reason why I can't get this done with my experience level)
Created a Custom Object Called DRF which has a Master-Detail relationship with the Opportunity Object.  
The Opportunity Object has a Lookup relationship with the custom DRF object (Not sure if I need this)
Have watched and completed the 2016 Visualforce Workbook (A few times now)

What I want to accomplish:
I would like for my sales staff to be able to click a detail button from within the Opportunity Object that launches a visualforce page.  This page would include fields to input customer's responses.  (I want a visualforce page so that I can include helpful discovery questions for the users to have infront of them as well as links to more detailed discovery questions for them to utilize.)  These responses will reside in the DRF object.  

I will also use this data to populate e-mail templates for the users to send to clients to recap their discussions.  (We are in a heavy technical industry that can really get into the weeds quickly so it is nice to have a written copy of everything for them to review).

The problem I keep running into is I can not get the Visualforce page "pull" the DRF fields when I have the controller set to Opportunity. I had given up on that working so I went to using the DRF as the controll. Now I can figure out how to get the Visualforce page to update the correct record.

Page 13 of the workbook says that I should just have to {!opportunity.RDF__c.ExampleField} but I can never get that to work.  I have also tried __r and many other various ways.  

I really appreciate any and all help the community can provide.  I am hiring 4 new associates but really want to have this new system up before they onboard so we can get them up and running sooner!  Thanks again.

Ugly Code from a Newbee...
<apex:page StandardController="DRF__c">
  <!-- Page Header -->
  <apex:sectionHeader title="Discovery" subtitle="Discovery and Red Flag Report" />
  <!-- Begin Form -->
  <apex:form >
    <apex:pageBlock title="Discovery" mode="edit">
      <!-- How to Use Text -->
      <apex:outputPanel styleClass="rules">
        Use this Report to help build your Discovery Letter Email as the information you add will autopopulate into the email template.<br /><br />
      </apex:outputPanel>
      <!-- Fields -->
      <apex:pageBlockSection columns="1" showHeader="true" title="Prospect's Challenge">
        <apex:inputField value="{!DRF__c.The_Challenge__c}" required="false" />
      </apex:pageBlockSection>
       <apex:pageBlockSection columns="1" showHeader="true" title="Current Situation">
        <apex:inputField value="{!DRF__c.Current_Solution__c}" required="false" />
        <apex:inputField value="{!DRF__c.Electrical_System__c}" required="false" />
        <apex:inputField value="{!DRF__c.Other_Options__c}" required="false" />
        <apex:inputField value="{!DRF__c.Requirements__c}" required="false" />
      </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" showHeader="true" title="Cost of Challenge">
        <apex:inputField value="{!DRF__c.Cost_of_Challenge__c}" required="false" />
      </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" showHeader="true" title="Next Steps">
        <apex:inputField value="{!DRF__c.Next_Steps__c}" required="false" />
      </apex:pageBlockSection>   
      <!-- Button Section -->
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Save" action="{!save}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
  </apex:form>
  <!-- CSS -->
  <style>

    .rules {
      color: black;
      font-size: 14px;
      font-family: Arial;      
      margin: 10px 0 10px 30px;
      float: left;
      width: 100%;
    }
  </style>
</apex:page>
deepak balur 19deepak balur 19
This is how it should be. I do not understand this comment "Now I can figure out how to get the Visualforce page to update the correct record." What happens when you click Save? Does the code as it stands pull the values correctly? Do you get an error? 
Jack KlausJack Klaus
Thank you for the response. The code above is what I resorted to when I thought I would have to have the associates click a custom button in the DRF related field when in the Opportunity. However, I can not get that button to populate. The same code is basically what I had when I was using the Opportunity controller (Which is what I really think I want to accomplish my objective). When I use it this way I get the following error: Error: Invalid field DRF__c for SObject Opportunity I even stripped everything down to just a simple field: ( and SF error is 'DRFs' is not a valid child relationship name for entity Opportunity *The code with Opportunity as the Controller:* Use this Report to help build your Discovery Letter Email as the information you add will autopopulate into the email template.

.rules { color: black; font-size: 14px; font-family: Arial; margin: 10px 0 10px 30px; float: left; width: 100%; }
deepak balur 19deepak balur 19
Jack, I went over the reqs and tried to replicate your env last night on my Sandbox. A quick fix: can you move the button to the Detail entity rather than on Opportunity. If yes, then please go ahead and try it. If No, then you need a CustomExtensionController to help you populate and edit Child records. I am going to provide you a link, please try and use it as your base for the design. http://bobbuzzard.blogspot.com/2011/03/edit-parent-and-child-records-with.html Good Luck !!! -Deepak
Jack KlausJack Klaus
Thank you for your help. In regards to the second option: I believe that is exactly what I need. However, it is my understanding that SF will not allow me to use Custom Extension Controllers as we only have a Professional License. On a related note, I was able to get the Visualforce page to at least display the information I want to edit with the attached code. However, I can not get the Child record (Discovery) to take the edits. I assume that is because I need the Custom Extension Controller. Again, thank you for helping me.

The Challenge the Customer Wants Solved