2017-12-19 24 views
0

* SF開発の新機能* 私はこの最終目標に向けて取り組んでいます。オポチュニティにカスタムボタンを作成します。そのボタンが押されると、Visualforceページには、そのオポチュニティ(ID)との関係を持つ2つのカスタムオブジェクトのレコードが表示されます。両方のカスタムオブジェクトは、カスタムルックアップフィールドを使用して案件に関連付けられます。APEXクラスVisualForceで使用する複数のクエリを一覧表示する

ルーキーとして、私は正しい場所で開始しているかどうかはわかりません。私の頭の中でどうしようとしているのです。下のコードは、#1 &#2のアイテムです。

  1. 個別のデータを照会するクラスメソッドを作成します。それぞれの方法は
  2. は、現在の機会ID
  3. の変数に引っ張ってコーディングする照会データ
  4. はAPEXコード

をトリガーするボタンを作成し表示するVisualforceページを作成します含める別のクエリ/リストになります
public with sharing class TestDisplayQueryList{ 

public Opportunity currRec {get; set;}  
public static List<Opportunity> oppRecords {get; set;} 
public static List<Billing__c> billRecords {get; set;} 
public static List<Service__c> servRecords {get; set;} 

public TestDisplayQueryList(){ 
currRec = [SELECT ID FROM Opportunity WHERE :ApexPages.currentPage().getParameters().get('id')]; 
oppRecords = [SELECT Name, StageName ID FROM Opportunity WHERE ID= :currRec]; 
billRecords = [SELECT Name, Invoice ID FROM Billing WHERE Opportunity_Name_c= :currRec]; 
servRecords = [SELECT Name, Department ID FROM Service WHERE Opportunity_Name_c= :currRec];  
} 
} 

答えて

0

3)これを行う方法の束があり、最も簡単なのは https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_iteration_components.htm

だけpageblockテーブルです

あなたのコントローラからあなたのリストとしてあなたの価値を置くならば、リストごとに別々のページブロックテーブルが必要になります。

4.) カスタムボタンまたはリンクを作成するには、salesforceカスタムボタンを使用します。これをURLにして、URLの最後に?idを渡します。これにより、ページの初期化時にコードを実行できるため、コードが自動的に実行されます。このボタンを案件ページに配置します。

情報をポップアップウィンドウに表示したい場合(システムで見た目が良くなります)、カスタムボタンを使用することもできます。ちょうどjavascriptボタンを使用します。 JavaScriptのポップアップウィンドウのボタンを作るためのオンラインのチュートリアルがたくさんあります。 javascriptをコントローラに渡して、機会IDも渡すことができます。

お困りの場合はお知らせください。

0

あなたが思うよりずっと簡単にこれを行うことができます。

VisualForceには、このようなタスクに使用できる豊富な標準コンポーネントがあります。以下は

あなたのための例Visualforceページです:

<apex:page standardController="Opportunity" extensions="OpportunityExt"> 

    <!-- Either include all related lists by setting the relatedList attribute to true --> 
    <apex:detail subject="{!opportunity.Id}" relatedList="false"/> 

    <!-- Or by Including the related lists seperately --> 
    <apex:relatedList list="OpportunityLineItems" /> 
    <apex:relatedList list="OpportunityCompetitors" /> 

    <!-- To use a button to display a panel, create the panel to reRender after our button action is complete --> 
    <apex:outputPanel id="thePanel"> 

     <!-- Then create the buttons --> 
     <apex:commandButton action="{!showThePanel}" value="Show Panel" reRender="thePanel" rendered="{!NOT(showPanel)}"/> 
     <apex:commandButton action="{!hideThePanel}" value="Hide Panel" reRender="thePanel" rendered="{!showPanel}"/> 

     <!-- And inside that panel create a block that will only render when the flag is set --> 
     <!-- Note the use of outputPanel and outputText differently --> 
     <!-- OutputText leaves no container behind, outputPanel does so we need it for the "identifying panel" --> 
     <apex:outputText rendered="{!showPanel}"> 

      <!-- You can then include the related lists you wanted --> 
      <apex:relatedList list="OpenActivities" /> 

     </apex:outputText> 

    </apex:ouputPanel> 

</apex:page> 

そしてこれは、そのページの拡張子を次のようになります。ここにあなたの参考のために

public with sharing class OpportunityExt { 

    private Opportunity theOpportunity; 
    public Boolean showPanel {get; private set;} 

    public OpportunityExt(ApexPages.StandardController controller) { 

     // Get the Opportunity from the standard controller 
     theOpportunity = (Opportunity) controller.getRecord(); 

     // By default don't display the panel - or do, it's your task 
     showPanel = false; 

    } 

    public void showThePanel() { 

     showPanel = true; 

    } 

    public void hideThePanel() { 

     showPanel = false; 

    } 

} 

ドキュメントへのリンクです:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_detail.htm https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_relatedList.htm https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_commandButton.htm https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputPanel.htm https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm

関連する問題