• Tescalante
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

Hi All,

 

I'm new to this (admin moving to code) so I apolgize if this seems like an exceedingly simple question. I've looked in the VF workbook and looked at a few other examples online and they all seemed a little too complex for what I'm trying to do.

 

I've created a custom button on the Contract object with the following setup:

Label: Edit

Name: Console_Edit

Behavior: Display in existing window without sidebar

Content Source: Visualforce Page

Height (in pixels): 600

Display Type: Detail page Button

Visualforce Page: Console: Account Mini Page Edit Mode

 

I'm trying to set up some small visualforce pages for one of our service cloud consoles but realized that the standard view, edit, and save buttons try to render the whole detail page within the tiny area of a console component. To go around this I set up two visualforce pages: a mini detail and a mini edit. For my edit button in the console (the custom button I am trying to create) I set it to redirect to the edit page.

 

My challenge comes in trying to reference to this button in the detail layout. 

 

<apex:page standardController="Contract">
  <apex:form >
    <apex:pageblock tabStyle="Account" id="pageblock" mode="detail" title="Account Detail">
    <apex:pageBlockButtons >
        <apex:commandButton action="{!Console_Edit}" id="editButton" value="Edit"/>
    </apex:pageBlockButtons>
        <apex:pageBlockSection title="Account Details" columns="1" ShowHeader="false" collapsible="false">
            <apex:outputField style="text-align:left" value="{!Contract.AccountId}"/>
            <apex:outputField style="text-align:left" value="{!Contract.Account.Phone}" />
            <apex:outputField style="text-align:left" value="{!Contract.Account.ParentId}" />
            <apex:outputField style="text-align:left" value="{!Contract.Account.Customer_ID__c}" />
            <apex:outputField style="text-align:left" value="{!Contract.Account.Tax_ID__c}" />
        </apex:pageblocksection>
    </apex:pageblock>
  </apex:form>
</apex:page>

 

I would assume that the custom button I created would still use the standard Contract conroller since the functionality is designed in the Custom Buttons and Links within salesforce and not a class. Is this not the case? Or is there different way to reference a custom button? How do I go about getting the button I defined on this particular visualforce page?

 

Please, it's probably a minor error I am missing, but can someone tell me what I am missing?

 

I want to reproduce the basic functionality of this table, copied directly from the VF Dev guide:

 

<apex:page standardController="Account">
   <apex:pageBlock title=" {!$User.FirstName}!">
      {!account.name} account report.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!account.Contacts}" var="contact">
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

 But when I use my objects in this code:

 

<apex:page standardController="Customobject__c">
   <apex:pageBlock title=" {!$User.FirstName}!">
       {!Customobject__c.name} CDI Report.
   </apex:pageBlock>
    <apex:pageBlock title="Transcripts">
   <apex:pageBlockTable value="{!Customobject__c.CustomRelatedObj__c}" var="CustomRelatedObj__c">
         <apex:column value="{!CustomRelatedObj__c.Status__c}"/>
         <apex:column value="{!CustomRelatedObj__c.Knight_Products__c}"/>
         <apex:column value="{!CustomRelatedObj__c.Author__c}"/>
      </apex:pageBlockTable>
  </apex:pageBlock> 
</apex:page>

 I get error:

Error: Invalid field Transcript__c for SObject Client_Development_Initiative__c

 

I don't understand. Why does one of these lines work and not the other?

<apex:pageBlockTable value="{!account.Contacts}" var="contact">

<apex:pageBlockTable value="{!Customobject__c.CustomRelatedObj__c}" var="CustomRelatedObj__c">

 

Hi,

I'm trying to create a custom detail view for a custom object and implement inline edits. However, the page is not only used to edit the custom object (Test_Parent__c) but also its related objects (Test_Child__c). Here is the controller:

 

 

public class TestController
{

    public Test_Parent__c rep {get; set;}
    public List<Test_Child__c> recs {get; set;} 
    
    public TestController() {
        String id = ApexPages.currentPage().getParameters().get('id');

        rep = [select id, Test_Text__c from Test_Parent__c where Id = :id][0];
        recs = [select id, Hours__c from Test_Child__c where Test_Parent__r.Id = :rep.Id];
    }

    public PageReference save() {
        update rep;
        update recs;
        return null;
    }

}

 and here is the visualforce for this page:

 

 

<apex:page controller="TestController" > 
<apex:form >
<apex:commandButton action="{!save}" id="saveButton" value="Save"/>
<apex:inlineEditSupport>
  <table border="1" bordercolor="black">
      <tr>
          <td>Parent Name:</td><td><apex:outputField value="{!rep.Test_Text__c}" ><apex:inlineEditSupport />
          </apex:outputField></td>
      </tr>
  </table>
<apex:repeat value="{!recs}" var="rec">
    Child Hours: <apex:outputField value="{!rec.Hours__c}"><apex:inlineEditSupport />
          </apex:outputField>
</apex:repeat>
</apex:inlineEditSupport>
</apex:form>
</apex:page>

Now, when I use the inline edit feature, the parent rep objects gets update and the child does not get updated. I played around with placing the inlineEditSupport tag inside the form and also inside the individual outputField records. I wasn't able to get this to work consistently to update both records at the same time. I would sometimes see that the child related record will get updated and most times it would not. 

 

Any suggestions or ideas?

 

 

I'd like to have a VisualForce page that allows editing fields from both a master record and its associated detail records.  I'm close, but it doesn't seem to save the changes to the detail records.

 

It makes sense to me that the standardController for the master record would not update all the detail records, so I've tried updating the detail records in a controller extension.  It doesn't seem to work.

 

Can someone please tell me if I've gone off course and where? 

 

 

<apex:page standardController="Master__c" extensions="masterExtension" tabstyle="Master__c" sidebar="false" > <apex:form > <apex:pageBlock mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:inputField value="{!Master__c.name}"/> <apex:pageBlockTable value="{!Master__c.Detail__r}" var="detail"> <apex:column value="{!detail.name}"/> <apex:column headerValue="Detail Field"> <apex:inputField value="{!detail.detail_field__c}"/> </apex:column> more columns here </apex:pageBlockTable> </apex:pageBlock></apex:pageBlock>

 

 

public class masterExtension { private final Master__c master; private final ApexPages.standardController theController; public masterExtension(ApexPages.StandardController stdController) { this.master = (Master__c)stdController.getRecord(); theController = stdController; //I'm guessing here. I received a Null Pointer Exception without it } public PageReference save() { List<Detail__c> addDetails = [Select ID from Detail__c Where Detail__c.Master_Field__c = :master.ID]; update addDetails; return theController.save(); }}

 

.