• Netmaster
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies

I'm attempting to create my first VF page. It is a line-item entry form that will allow a user to enter multiple child records (Enfants_c) before clicking save. Right now, I'm opening the VF page from a custom button on the parent (Assure_c). However, when the page opens, the lookup field for the parent is not populated - so the user has to click the lookup to select the parent from Assure__c. Is there a way to pass the parent id of the previous page to the new child records on the VF page ?

 

<apex:page standardController="Enfants__c" extensions="insererEnfants" standardStylesheets="true">
    <apex:sectionHeader title="Ajouter un enfant"
        subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="Nouveau enfant" id="thePageBlock" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Enregistrer"></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="   Annuler   "></apex:commandButton>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!accts}" var="a" id="table">
                <apex:facet name="footer">
                    <apex:commandLink value="Ajouter" action="{!addRow}" rerender="table,error"/>
                </apex:facet>
                <apex:facet name="header">
                    <apex:commandLink value="Supprimer" action="{!deleteRow}" rerender="table,error"/>
                </apex:facet>
                
                <apex:column headerValue="Nom">
                    <apex:inputField/> value="{!a.Parent__c}"/>
                </apex:column>
                <apex:column headerValue="Nom">
                    <apex:inputField value="{!a.Name}"/>
                </apex:column>
                <apex:column headerValue="Prénom">
                    <apex:inputField value="{!a.Prenom__c}"/>
                </apex:column> 
                                <apex:column headerValue="Né le">
                    <apex:inputField value="{!a.Date_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Lieu de naissance">
                    <apex:inputField value="{!a.Lieu_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Situation">
                    <apex:inputField value="{!a.Situation__c }"/>
                </apex:column>                          
            </apex:pageBlockTable>



            </apex:pageblock>
    </apex:form>
</apex:page>
public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c();

    }
    
    public void addrow(){
        accts.add(new Enfants__c());       
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 

 

I'm attempting to create my first VF page. It is a line-item entry form that will allow a user to enter multiple child records (Enfants_c) before clicking save. Right now, I'm opening the VF page from a custom button on the parent (Assure_c). However, when the page opens, the lookup field for the parent is not populated - so the user has to click the lookup to select the parent from Assure__c. Is there a way to pass the parent id of the previous page to the new child records on the VF page ?

 

<apex:page standardController="Enfants__c" extensions="insererEnfants" standardStylesheets="true">
    <apex:sectionHeader title="Ajouter un enfant"
        subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="Nouveau enfant" id="thePageBlock" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Enregistrer"></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="   Annuler   "></apex:commandButton>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!accts}" var="a" id="table">
                <apex:facet name="footer">
                    <apex:commandLink value="Ajouter" action="{!addRow}" rerender="table,error"/>
                </apex:facet>
                <apex:facet name="header">
                    <apex:commandLink value="Supprimer" action="{!deleteRow}" rerender="table,error"/>
                </apex:facet>
                
                <apex:column headerValue="Nom">
                    <apex:inputField/> value="{!a.Parent__c}"/>
                </apex:column>
                <apex:column headerValue="Nom">
                    <apex:inputField value="{!a.Name}"/>
                </apex:column>
                <apex:column headerValue="Prénom">
                    <apex:inputField value="{!a.Prenom__c}"/>
                </apex:column> 
                                <apex:column headerValue="Né le">
                    <apex:inputField value="{!a.Date_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Lieu de naissance">
                    <apex:inputField value="{!a.Lieu_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Situation">
                    <apex:inputField value="{!a.Situation__c }"/>
                </apex:column>                          
            </apex:pageBlockTable>



            </apex:pageblock>
    </apex:form>
</apex:page>
public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c();

    }
    
    public void addrow(){
        accts.add(new Enfants__c());       
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 


I want to insert the ID of the parent in this line

accts.add(new Enfants__c(Parent__c='01rd00000002OBC'));

 

 instead in this 

01rd00000002OBC

 

Is this even possible? What other ways would you suggest going about this?

 

public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c(Parent__c='01rd00000002OBC'));
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
        Set<ID> resourceIds = new Set<ID>();

        resourceIds.add(accts[0].Parent__c);  

        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 

I want to get the parent ID in my child custom controller. How can I do this, please ?

Hello,

 

I use in my force.com application Apex Classes, and many of them have the same structure, I want to make an API to reuse it after.

 

For exaple, these are two classes :

 

public class insererActAct{

    public List<Activites_actuelles__c> accts {get; set;}
    
    public insererActAct(ApexPages.StandardController controller){
        accts = new List<Activites_actuelles__c>();
        accts.add(new Activites_actuelles__c());
    }
    
    public void addrow(){
        accts.add(new Activites_actuelles__c());
        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Activites_actuelles__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

public class insererEnfants{

    public List<Enfants__c> accts {get; set;}
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c());
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

Can any one tell me it is possible or not, if yes, how can I do this, please ?

Hello,

 

I want to redirect my page after saving to the details page just created, but I have an error :

 

public class insererEnfants{


public List<Enfants__c> accts {get; set;}

public insererEnfants(ApexPages.StandardController controller){
    accts = new List<Enfants__c>();
    accts.add(new Enfants__c());
}

public void addrow(){
    accts.add(new Enfants__c());
}

public PageReference save(){
    insert accts;
    PageReference acctPage = new ApexPages.StandardController(accts).view();
    acctPage.setRedirect(true);
    return acctPage;
}
}

 Here is the error :


Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Enfants__c> at line 19 column 45

 Can you help me, please ?



Hello,

 

I saved this code to an apex class, but when I want to utilise it I  get an error :

 

public class insererEnfant{

    public List<Enfants__c> accts {get; set;}
    
    public insererEnfant(){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c());
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
    }
    
    public PageReference save(){
        insert accts;
        PageReference home = new PageReference('/home/home.jsp');
        home.setRedirect(true);
        return home;
    }
}

 The error :

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Assuré]: [Assuré] 
Class.insEnfant.save: line 15, column 1

 How can solve this problem, please ?

I'm attempting to create my first VF page. It is a line-item entry form that will allow a user to enter multiple child records (Enfants_c) before clicking save. Right now, I'm opening the VF page from a custom button on the parent (Assure_c). However, when the page opens, the lookup field for the parent is not populated - so the user has to click the lookup to select the parent from Assure__c. Is there a way to pass the parent id of the previous page to the new child records on the VF page ?

 

<apex:page standardController="Enfants__c" extensions="insererEnfants" standardStylesheets="true">
    <apex:sectionHeader title="Ajouter un enfant"
        subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="Nouveau enfant" id="thePageBlock" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Enregistrer"></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="   Annuler   "></apex:commandButton>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!accts}" var="a" id="table">
                <apex:facet name="footer">
                    <apex:commandLink value="Ajouter" action="{!addRow}" rerender="table,error"/>
                </apex:facet>
                <apex:facet name="header">
                    <apex:commandLink value="Supprimer" action="{!deleteRow}" rerender="table,error"/>
                </apex:facet>
                
                <apex:column headerValue="Nom">
                    <apex:inputField/> value="{!a.Parent__c}"/>
                </apex:column>
                <apex:column headerValue="Nom">
                    <apex:inputField value="{!a.Name}"/>
                </apex:column>
                <apex:column headerValue="Prénom">
                    <apex:inputField value="{!a.Prenom__c}"/>
                </apex:column> 
                                <apex:column headerValue="Né le">
                    <apex:inputField value="{!a.Date_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Lieu de naissance">
                    <apex:inputField value="{!a.Lieu_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Situation">
                    <apex:inputField value="{!a.Situation__c }"/>
                </apex:column>                          
            </apex:pageBlockTable>



            </apex:pageblock>
    </apex:form>
</apex:page>
public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c();

    }
    
    public void addrow(){
        accts.add(new Enfants__c());       
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 

 

I'm attempting to create my first VF page. It is a line-item entry form that will allow a user to enter multiple child records (Enfants_c) before clicking save. Right now, I'm opening the VF page from a custom button on the parent (Assure_c). However, when the page opens, the lookup field for the parent is not populated - so the user has to click the lookup to select the parent from Assure__c. Is there a way to pass the parent id of the previous page to the new child records on the VF page ?

 

<apex:page standardController="Enfants__c" extensions="insererEnfants" standardStylesheets="true">
    <apex:sectionHeader title="Ajouter un enfant"
        subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="Nouveau enfant" id="thePageBlock" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Enregistrer"></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="   Annuler   "></apex:commandButton>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!accts}" var="a" id="table">
                <apex:facet name="footer">
                    <apex:commandLink value="Ajouter" action="{!addRow}" rerender="table,error"/>
                </apex:facet>
                <apex:facet name="header">
                    <apex:commandLink value="Supprimer" action="{!deleteRow}" rerender="table,error"/>
                </apex:facet>
                
                <apex:column headerValue="Nom">
                    <apex:inputField/> value="{!a.Parent__c}"/>
                </apex:column>
                <apex:column headerValue="Nom">
                    <apex:inputField value="{!a.Name}"/>
                </apex:column>
                <apex:column headerValue="Prénom">
                    <apex:inputField value="{!a.Prenom__c}"/>
                </apex:column> 
                                <apex:column headerValue="Né le">
                    <apex:inputField value="{!a.Date_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Lieu de naissance">
                    <apex:inputField value="{!a.Lieu_de_naissance__c}"/>
                </apex:column>   
                                <apex:column headerValue="Situation">
                    <apex:inputField value="{!a.Situation__c }"/>
                </apex:column>                          
            </apex:pageBlockTable>



            </apex:pageblock>
    </apex:form>
</apex:page>
public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c();

    }
    
    public void addrow(){
        accts.add(new Enfants__c());       
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 


I want to insert the ID of the parent in this line

accts.add(new Enfants__c(Parent__c='01rd00000002OBC'));

 

 instead in this 

01rd00000002OBC

 

Is this even possible? What other ways would you suggest going about this?

 

public class insererEnfants{

    
    public List<Enfants__c> accts {get; set;}
    
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c(Parent__c='01rd00000002OBC'));
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
        Set<ID> resourceIds = new Set<ID>();

        resourceIds.add(accts[0].Parent__c);  

        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

 

I want to get the parent ID in my child custom controller. How can I do this, please ?

Hello,

 

I use in my force.com application Apex Classes, and many of them have the same structure, I want to make an API to reuse it after.

 

For exaple, these are two classes :

 

public class insererActAct{

    public List<Activites_actuelles__c> accts {get; set;}
    
    public insererActAct(ApexPages.StandardController controller){
        accts = new List<Activites_actuelles__c>();
        accts.add(new Activites_actuelles__c());
    }
    
    public void addrow(){
        accts.add(new Activites_actuelles__c());
        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Activites_actuelles__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

public class insererEnfants{

    public List<Enfants__c> accts {get; set;}
    
    public insererEnfants(ApexPages.StandardController controller){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c());
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
        
    }
    
    public PageReference deleteRow(){
       if (accts.size()>1)
       {
          accts.remove(accts.size()-1);
       }
       return null;
    }
    
    public PageReference save()
    {
        insert accts;
        Assure__c theParent = new Assure__c(id=accts[0].Parent__c);
        PageReference acctPage = new ApexPages.StandardController(theParent).view();
        acctPage.setRedirect(true);
        return acctPage;
    }
}

 

Can any one tell me it is possible or not, if yes, how can I do this, please ?

Hello,

 

I want to redirect my page after saving to the details page just created, but I have an error :

 

public class insererEnfants{


public List<Enfants__c> accts {get; set;}

public insererEnfants(ApexPages.StandardController controller){
    accts = new List<Enfants__c>();
    accts.add(new Enfants__c());
}

public void addrow(){
    accts.add(new Enfants__c());
}

public PageReference save(){
    insert accts;
    PageReference acctPage = new ApexPages.StandardController(accts).view();
    acctPage.setRedirect(true);
    return acctPage;
}
}

 Here is the error :


Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Enfants__c> at line 19 column 45

 Can you help me, please ?



Hello,

 

I saved this code to an apex class, but when I want to utilise it I  get an error :

 

public class insererEnfant{

    public List<Enfants__c> accts {get; set;}
    
    public insererEnfant(){
        accts = new List<Enfants__c>();
        accts.add(new Enfants__c());
    }
    
    public void addrow(){
        accts.add(new Enfants__c());
    }
    
    public PageReference save(){
        insert accts;
        PageReference home = new PageReference('/home/home.jsp');
        home.setRedirect(true);
        return home;
    }
}

 The error :

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Assuré]: [Assuré] 
Class.insEnfant.save: line 15, column 1

 How can solve this problem, please ?