Bonjour,

Une premiere precision je travaille sur Lightning Experience (la nouvelle interface utilisateur) et en anglais donc je m'excuse par avance si les noms sont anglicanises....
J'ai cree un Lightning Component pour la page Opportunite (details) qui affiche 7 boutons. Chacun ouvre une VF Page differente. Il s'agit de Forms pour collecter des informations pour un Custom Object (Fact_Finder__c) (Master-detail relashionship avec Opportunite). Chaque boutons cree un RecordType different pour le meme Object. J'ai une seule APEX Class pour les 7 VF Pages qui utilise le standard controller Fact_Finder__c et une extension. 6 pages fonctionnent parfaitement bien. La 7eme est plus compliquee et c'est la que ma logique ne fonctionne plus.
Cette page a un bouton supplementaire qui ouvre une autre VF Page basee sur 1 nouveau Custom Object (FFDriver__c) (Master-detail relationship avec Fact_Finder__c). Meme design que pour les autres VF pages, Form qui collecte des informations pour creer un nouveau Record. Je dois avoir la possibilite de creer plusieurs Driver soit sur la nouvelle VF Page soit chaque fois en selectionnant mon bouton sur la 1ere VF Page. Pour l'instant ma VF Page Driver a son proper Controller.
J'ai vu des solutions avec une seule APEX Class (Wizard) mais cela ne fonctionne pas lorsque j'ai essaye de le mettre en place car j'ai beaucoup de champs en je navigue plusieurs fois entre les Pages. J'ai aussi envisage la possibilite de rajouter plusieurs Records sous forme de List mais la aussi j'en ai trop pour une seule ligne.

J'espere avoir ete suffisamment precise. Au cas ou cela ne serait pas le cas je sui desolee. Je vais donc mettre des mes codes simplifies (sans style et avec beaucoup moins de champs) en esperant que quelqu'un pourra m'aider. Merci d'avance.
Sylvie

1er VF Page

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<apex:page standardcontroller="Fact_Finder__c" extensions="FFFormCtrExt" showHeader="false" sidebar="false" >    
 <apex:form style="width:800px; text-align:center; margin:auto;" enctype="multipart/form-data" > 
  <apex:pageMessages />
   <apex:pageBlock id="block" title="Motor Fact Finder" >        
     <apex:pageBlockButtons location="bottom" > 
            <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" styleClass="buttoncancel" />
            <apex:commandButton action="{!saveFF}" value="Submit" styleclass="buttonsubmit" /> 
     </apex:pageBlockButtons> 
      <apex:outputPanel styleClass="black" layout="block">
              <apex:pageblocksection columns="1">                 
                    <apex:inputfield value="{!FF.Opportunity_Name__c}"/>            
                    <apex:inputfield value="{!FF.Client_Name__c}"/>
                    <apex:inputfield value="{!FF.Date__c}"/>
                    <apex:selectRadio value="{!FF.Attached_to__c}" > 
                      <apex:selectOption itemValue="Business Pack" itemlabel="Business Pack"  />
                      <apex:selectOption itemValue="Farm Pack" itemlabel="Farm Pack"/>
                    </apex:selectRadio>                    
   </apex:pageblocksection>  
</apex:outputPanel>             
    <apex:outputPanel styleClass="black" layout="block">
     <apex:pageblocksection title="Drivers" showheader="true" collapsible="true" id="DriverList" columns="1">                    
                    <apex:outputText value="Any Driver who drives more than 12 times any one year:" style="font-weight: bold;" />                                            
                  <apex:commandButton value="Add Driver" action="{!addDriver}" rerender="DriverList" immediate="true" styleClass="buttoncancel" />                
            <apex:pageBlockTable value="{!driverList}" var="driv" columnsWidth="30%,15%,15%,10%,15%,15%">
                    <apex:column headerValue="Name">
                    <apex:commandLink value="{!driv.Driver_Name__c}" action="/{!driv.Id}" target="_blank" />
                    </apex:column> 
                    <apex:column headerValue="DOB" value="{!driv.Date_of_Birth__c}"/>
                    <apex:column headerValue="Gender" value="{!driv.Gender__c}"/>
                    <apex:column >
                        <apex:facet name="header"> License<br/>Class </apex:facet>
                         value="{!driv.Class_of_License__c}"/>
                    </apex:column>
                    <apex:column >
                         <apex:facet name="header"> License<br/>No.</apex:facet>
                           value="{!driv.Licence_Number__c}"/>
                    </apex:column>
                    <apex:column >
                         <apex:facet name="header">Years<br/>Licensed</apex:facet>
                          value="{!driv.Years_Licenced__c}"/>
                    </apex:column>                     
                  </apex:pageBlockTable>              
     </apex:pageblocksection>
  </apex:outputPanel>
    <apex:outputPanel styleClass="black" layout="block">
      <apex:pageblocksection title="Other Information" showheader="true" collapsible="true" columns="1">
                   <apex:actionSupport event="onchange" action="{!readUser}" />
               <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Prepared by"/>
                    <apex:inputField value="{!FF.Owner__c}"/>            
               </apex:pageBlockSectionItem>
                    <apex:inputfield value="{!FF.Notes__c}"/>
       </apex:pageblocksection>                 
     </apex:outputPanel>
     </apex:pageBlock>     
   </apex:form>         
</apex:page>
1ere APEX Class

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public with sharing class FFFormCtrExt {

  public User selectedUser {get; set;}   
  public string CurrentPageName {get;set;}  
  public Opportunity opp {get;set;}
  string recordId = ApexPages.currentPage().getParameters().get('recordId'); 
  public Fact_Finder__c FF {get; set;} 
  string FFId = ApexPages.currentPage().getParameters().get('FFId');   
  public List <FFDriver__c> driverList {get; set;}
  
     public FFFormCtrExt(ApexPages.StandardController controller) {
    
       opp =  [SELECT Id, Name, ABN__c, ACN__c, Email__c, Phone__c, Address__c, Primary_Contact__c, Account.Name FROM Opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('recordId')];      
   
       this.FF=(Fact_Finder__c)controller.getRecord();           
                               
       //All forms       
       FF.Opportunity_Name__c= recordId; 
       FF.Client_Name__c= opp.AccountId;
       FF.Owner__c = UserInfo.getUserId();
       selectedUser = [ Select Id From User Where Id = :UserInfo.getUserId()];
       driverList = new List<FFDriver__c>();
       driverList = [select Id, Driver_Name__c, Date_of_Birth__c, Gender__c,  Class_of_License__c, Licence_Number__c, Years_Licenced__c from FFDriver__c where Motor_Fact_Finder_No__c = :ApexPages.currentPage().getParameters().get('FFId')];   
    
  }          
    public pageReference readUser()   {
        selectedUser = [ Select Id From User Where Id = :FF.Owner__c ];
        return null;      
    } 
   public PageReference addDriver()
    {
        FF.RecordTypeId= '01228000000U19O';         
        insert (This.FF);
        PageReference ref = new Pagereference('/apex/FFDriver');
        ref.getParameters().put('FFId', FF.Id);
        ref.getParameters().put('recordId', FF.Opportunity_Name__c);
        ref.setRedirect(true);
        return ref;
    }                
    public PageReference cancel(){   
     return new PageReference('/' + recordId);   
    }    
    public PageReference saveFF() {       
       
     RecordType rt;             
        if(CurrentPageName == 'HomeForm')
            rt = [Select Id From RecordType Where DeveloperName = 'Home_Contents' And sObjectType = 'Fact_Finder__c'];
        if(CurrentPageName == 'MotorForm')
            rt = [Select Id From RecordType Where DeveloperName = 'Motor' And sObjectType = 'Fact_Finder__c'];
         if(CurrentPageName == 'BusinessForm')   
            rt = [Select Id From RecordType Where DeveloperName = 'Business_Package' And sObjectType = 'Fact_Finder__c'];
        if(CurrentPageName == 'ContractForm')   
            rt = [Select Id From RecordType Where DeveloperName = 'Contract_Works' And sObjectType = 'Fact_Finder__c'];
        if(CurrentPageName == 'FarmForm')   
            rt = [Select Id From RecordType Where DeveloperName = 'Farm' And sObjectType = 'Fact_Finder__c'];
        if(CurrentPageName == 'AccidentForm')   
            rt = [Select Id From RecordType Where DeveloperName = 'Accident_Illness' And sObjectType = 'Fact_Finder__c'];
        if(CurrentPageName == 'PIForm')   
            rt = [Select Id From RecordType Where DeveloperName = 'Professional_Indemnity' And sObjectType = 'Fact_Finder__c'];          
        FF.RecordTypeId = rt.Id;             
    insert (this.FF);    
    return new PageReference('/' + recordId);    
      }      
  }
2eme VF Page

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<apex:page standardcontroller="FFDriver__c" extensions="FFDriverFormCtrExt" showHeader="false" sidebar="false" >
<apex:form style="width:800px; text-align:center; margin:auto;" enctype="multipart/form-data" > 
    <apex:pageBlock >     
     <apex:pageBlockButtons location="bottom" > 
           <apex:commandButton action="{!saveDriver}" value="Submit" immediate="true" styleclass="buttonsubmit" /> 
            <apex:commandButton action="{!doCancel}" value="Cancel" immediate="true" styleClass="buttoncancel" />
                </apex:pageBlockButtons> 
<apex:outputPanel styleClass="black" layout="block">
     <apex:pageblocksection title=" Driver Details" showheader="true" collapsible="true" columns="1">                    
                    <apex:outputText value="Any Driver who drives more than 12 times any one year:" style="font-weight: bold;" /> 
                    <apex:inputfield value="{!driv.Motor_Fact_Finder_No__c}" />                     
                    <apex:inputfield value="{!driv.Opportunity_Name__c}" rendered="false" />
                    <apex:inputfield value="{!driv.Driver_Name__c}" />
                    <apex:inputfield value="{!driv.Date_of_Birth__c}" />
                    <apex:inputfield value="{!driv.Years_Licenced__c}" />
                    <apex:selectRadio value="{!driv.Gender__c}">
                      <apex:selectOption itemValue="Male" itemlabel="Male" />
                      <apex:selectOption itemValue="Female" itemlabel="Female" />
                    </apex:selectRadio>  
                    <apex:inputfield value="{!driv.Class_of_License__c}" />
                  <apex:inputfield value="{!driv.Licence_Number__c}" />                      
                  <apex:inputfield value="{!driv.Notes__c}" />
       </apex:pageblocksection>                 
     </apex:outputPanel>              
     </apex:pageBlock> 
   </apex:form>         
</apex:page>
2eme APEX Class

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public with sharing class FFDriverFormCtrExt {

  public Opportunity opp {get;set;}  
  string recordId = ApexPages.currentPage().getParameters().get('recordId');
  public Fact_Finder__c FF {get;set;}
  string FFId = ApexPages.currentPage().getParameters().get('FFId');
  public FFDriver__c driv {get;set;}
  string FFDId = ApexPages.currentPage().getParameters().get('FFDId');
      
    public FFDriverFormCtrExt (ApexPages.StandardController controller) {       
        
       FF = [SELECT Id, Name, Opportunity_Name__r.Name FROM Fact_Finder__c WHERE Id =:ApexPages.currentPage().getParameters().get('FFId')];           
       opp =  [SELECT Id, Name FROM Opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('recordId')];     
                   
       this.driv=(FFDriver__c)controller.getRecord();       
       driv.Motor_Fact_Finder_No__c = FFId; 

       driv.Opportunity_Name__c = recordId;      
             }             
    public PageReference doCancel(){    
        return new PageReference('/' + recordId);    
      }      
     public PageReference saveDriver(){      
    insert(this.driv);
    return new PageReference('/' + recordId);       
      }      
  }