• 1111_forcecom
  • NEWBIE
  • 40 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 15
    Replies
Hi developers,

First, thank you so much for your help in others questions.

Well now I have other question, I did all about development and test for apex clases. I test this classes in my visualforce page and it is ok. I deploy to production and the functionally not is the same.

Is there any reason for what it is happen?

Please help me, because I don't know what happened
Hi everybody

I have a rare problem, I did the apex class and the tests required in sandbox and works fine, but when I deploy this to production not visualization the same. The pagination doesn't work; In production can't modify anything and in sandbox works fine and I don't know how fix that.

Sometime happened to them something like this, please help me.

Regards,
Hi developers,

I need your help in a page that I want to display. The thing is that my page must be display a list of items with pagination because are so many.

I did this in my page

<apex:page StandardController="Contact" extensions="contactExtension">
    <apex:pageBlock title="Beneficios dolares">
        <apex:form id="theForm">
            <apex:pageBlockSection >
                <apex:dataList value="{!BeneficiosUsd}" var="beneficio" type="1">
                    {!beneficio.monto_estimado__c}
                </apex:dataList>
            </apex:pageBlockSection>
            <apex:panelGrid columns="2">
                <apex:commandLink action="{!previous}">Previous</apex:commandlink>
                <apex:commandLink action="{!next}">Next</apex:commandlink>
            </apex:panelGrid>
        </apex:form>
    </apex:pageBlock>
</apex:page>

And I have this error "Método 'ContactStandardController.previous()' desconocido"

This is my apex class
public class contactExtension {

    private final Contact contact;
    private string idContact;
    private final Moneda__c monedabob;
    private string idMonedabob;
    private final Moneda__c monedausd;
    private string idMonedausd;
    public decimal x {get;set;}
    public decimal totalUsd {get;set;}

    public contactExtension(ApexPages.StandardController contactController) {
       this.contact = (Contact)contactController.getRecord();
       idContact = contact.id;
    }
             
    public List<Beneficio__c> getBeneficiosUsd()
    {
        Moneda__c monedaUsd = [select Name from Moneda__c where Moneda__c.name = 'Dolares'];
        idMonedausd = monedausd.id;
       
        totalUsd = 0;
        for (Beneficio__c ben : [select monto_dolares__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd]){
            if (ben.monto_dolares__c == null){
                ben.monto_dolares__c = 0;
            }
            else{
                totalUsd = ben.monto_dolares__c + totalUsd;
            }
        }       
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_dolares__c, proposito__c,fecha_entrega__c  from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd];
    }
}
Hi developers,

I have my apex class deploy in my production instance and before I test this class and this was OK. When I try the implement my visualforce page I have this error "System.QueryException: List has more than 1 row for assignment to SObject" I prove this in my test instance and work fine. Please help me why is the problem.

This is my extension class

public class contactExtension {
    public contactExtension(ApexPages.StandardController contactController) {
       this.contact = (Contact)contactController.getRecord();
       idContact = contact.id;
    }
        
    public List<Beneficio__c> getBeneficiosBob()
    {
        Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
        idMonedabob = monedabob.id;
        x = 0;
        for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
            if (ben.monto_estimado__c == null){
                ben.monto_estimado__c = 0;
            }
            x = ben.monto_estimado__c + x;
        }
              
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob];
    }          
}

This is my visualforce page

<apex:page StandardController="Contact" extensions="contactExtension" >
  <apex:pageBlock title="Beneficios Bolivianos">
    <apex:pageBlockTable value="{!BeneficiosBob}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px,30px" rules="all">
        <apex:column value="{!beneficio.Name}"/>
        <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
        <apex:column value="{!beneficio.Moneda__c}"/>
        <apex:column value="{!beneficio.monto_estimado__c}" style="text-align:right;"/>
        <apex:column value="{!beneficio.proposito__c}"/>
        <apex:column value="{!beneficio.fecha_entrega__c}"/>
    </apex:pageBlockTable>
      <div class="resaltado">
         Total Bolivianos:       
         <apex:outputText value="{0,number,#,##0.00}" style="padding-left: 10px;">   
           <apex:param value="{!x}"/>
         </apex:outputText>
      </div>
  </apex:pageBlock>
</apex:page>

Regards,
Hi developers,

In this opportunity my question comes from about the test classes and coverage from this to apex classes

I have two classes, one is Apex Class and the other is the Test Class. My question is why my Apex Class is 0% coverage??? Run the test class and this finish OK. Please guide me how can I for coverage the code in my Apex Class?

I put the code from the two classes.

Thanks for the support 

APEX CLASS 

public class contactExtension {

    private final Contact contact;
    private string idContact;
    private final Moneda__c monedabob;
    private string idMonedabob;
    private final Moneda__c monedausd;
    private string idMonedausd;
    public decimal x {get;set;}
    public decimal totalUsd {get;set;}

    public contactExtension(ApexPages.StandardController contactController) {
       this.contact = (Contact)contactController.getRecord();
       idContact = contact.id;
    }
         
    public List<Beneficio__c> getBeneficiosBob()
    {
        Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
        idMonedabob = monedabob.id;
        x = 0;
        for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
            if (ben.monto_estimado__c == null){
                ben.monto_estimado__c = 0;
            }
            x = ben.monto_estimado__c + x;
        }
               
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob];
    }
             
    public List<Beneficio__c> getBeneficiosUsd()
    {
        Moneda__c monedaUsd = [select Name from Moneda__c where Moneda__c.name = 'Dolares'];
        idMonedausd = monedausd.id;
       
        totalUsd = 0;
        for (Beneficio__c ben : [select monto_dolares__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd]){
            totalUsd = ben.monto_dolares__c + totalUsd;
        }       
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_dolares__c, proposito__c,fecha_entrega__c  from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd];
    }
}

TEST CLASS

@isTest public class ContactTest {          
        testMethod private static void getBeneficiosBob()
        {
            Account a= new Account(Name = 'Fundacion Inti Raymi');
            insert a;
           
            Operacion__c operacion= new Operacion__c(Name = 'Kori Chaca');
            insert operacion;
           
            Departamento__c departamento = new Departamento__c(Name = 'Oruro');
            insert departamento;
           
            Provincia__c provincia= new Provincia__c(Name = 'Cercado', Departamento__c = departamento.id);
            insert provincia;
           
            Municipio__c municipio= new Municipio__c(Name = 'Caracollo', Provincia__c = provincia.id);
            insert municipio;
           
            Comunidad__c comunidad= new Comunidad__c(Name = 'Iroco');
            insert comunidad;           
           
            Organizacion__c organizacion= new Organizacion__c (Name = 'Iroco');
            insert organizacion;
                                               
            Moneda__c monedabob = new Moneda__c(Name = 'Bolivianos', sigla__c = 'BOB');
            insert monedabob;
           
            Contact contacto = new Contact(Firstname= 'Alejandra', Lastname = 'Helguero', Carnet_Identidad__c = '22334455', Operacion__c = operacion.id, Departamento__c = departamento.id, Provincia__c = provincia.id, Municipio__c = municipio.id, Comunidad__c = comunidad.id, Organizacion__c = organizacion.id);
            insert contacto;

            Categoria_beneficio__c categoria = new Categoria_beneficio__c(Name = 'Produccion Ganadera');
            insert categoria;
           
            Subcategoria_beneficio__c subcategoria = new Subcategoria_beneficio__c(Name = 'Ganaderos', Categoria_Beneficio__c = categoria.id);
            insert subcategoria;
           
            Catalogo_beneficios__c tipo_beneficio= new Catalogo_beneficios__c(Name= 'Sanidad Animal', Nombre__c = 'Sanidad Animal', Categoria_Producto__c = categoria.id, Subcategoria_producto__c = subcategoria.id);
            insert tipo_beneficio;           
           
            for(Integer i = 0; i < 20; i++){
                Beneficio__c b = new Beneficio__c(Contacto__c = contacto.id, Moneda__c = monedabob.id, monto_estimado__c = 100.56, Catalogo_Beneficio__c = tipo_beneficio.id, fecha_entrega__c = Date.newInstance(2014, 06 ,20));
                insert b;
            }           
           
            Moneda__c monedabobS = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
            String idMonedabob = monedabobS.id;
           
            Decimal x = 0;
            for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :contacto.id and Moneda__c = :monedabob.id]){
                if (ben.monto_estimado__c == null){
                    x = ben.monto_estimado__c + x;
                }
            }
            Beneficio__c[] beneficios = [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :contacto.id and Moneda__c = :monedabob.id];
            System.assert(beneficios != null, 'Retorna valores');
        }
}

Hi everybody,

 

Can you help me please, i have this error in my apex class test, and I don't know for why

 

ERROR: Error de compilación: Invalid constructor name: contactExtension en la línea 3 columna 16

 

@isTest 

public class ContactTest {
public contactExtension(ApexPages.StandardController contactController) {
this.contact = (Contact)contactController.getRecord();
String idContact = contact.id;
}

static testmethod void myTestMethod1() {
Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
System.assert(monedabob != null);
String idMonedabob = monedabob.id;
Double x = 0;
for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
x = ben.monto_estimado__c + x;
}

}
}

 

Regard,

 

Ale

Hello everybody,

 

Is possible display a blockTable in the if statement. Please tell me how can I do that?

 

Regards,

Hi,

 

I try to display this number with the following format 1.750,00 How can I do for obtain this?

The values for a apex:pageBlockTable, in the column the values show with this format, but in apex:outputText not work.      

 

Please help me, I try this:

 

<apex:outputText value="{0,number,#.##0,00}">    
    <apex:param value="{!totalUsd}"/>
</apex:outputText>

 

Regards,

Hello every body, I don't know why can't display the results in my visualforce page. The page don't show error only is empty

Please help me, I try to display the contacts in a family with their benefits

 

This is my visualforce page

 

<apex:page StandardController="Sayana__c" extensions="familiaExtension">
  <apex:pageBlock title="Beneficios">
  <apex:pageBlockTable value="{!BeneficiosTodos}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
     <apex:column value="{!beneficio.Contacto__c}"/>
     <apex:column value="{!beneficio.fecha_entrega__c}"/>
  </apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

and this is the apex class

 

public class familiaExtension {

    private final Sayana__c sayana;
    private string idSayana;
    private final Contact contacto;    
    private final Beneficio__c[] beneficios;

    public familiaExtension(ApexPages.StandardController sayanaController) {
       this.sayana = (Sayana__c)sayanaController.getRecord();
       idSayana = sayana.id;
    }

    public List<Beneficio__c> getBeneficiosTodos()
    {
       for(Contact contact : [SELECT  id, Name from Contact where Sayana__c = :idSayana]){
           Beneficio__c[] beneficios  = contact.Beneficios__r;
       }       
       return beneficios;
    }
}

 

 

Let me explain. I have an structure where I have three Objects, Contact, Benficio__c, Sayana__c. One Sayana__c have many Contacts, and one Contact have many Beneficios.

 

I try to display all contacts in a sayana__c and in each contact his beneficios. I have the following instructions in visualforce page.

 

<apex:pageBlockTable value="{!ContactosTodos}" var="contact" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
     <apex:column value="{!contact.Name}"/>
     <apex:pageBlockTable value="{!contact.Beneficio__r}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
         <apex:column value="{!beneficio.Name}"/>
         <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
         <apex:column value="{!beneficio.Moneda__c}"/>
         <apex:column value="{!beneficio.monto_estimado__c}"/>
         <apex:column value="{!beneficio.proposito__c}"/>
     </apex:pageBlockTable>
  </apex:pageBlockTable>

 

For last, let me know where I can see how is the names of relations in salesforce between objects?  I think that will help me so much.

 

Regards,

Hi my name is Alejandra,

 

I try to display in a column an variable that change with condition. The thing is that the variable set the last value, and not iterate with rows of table.

 

<apex:pageBlockTable value="{!contact.Beneficios__r}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
        <apex:column value="{!beneficio.Name}"/>
        <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
        <apex:column value="{!beneficio.Moneda__c}"/>
        if({!beneficio.monto_estimado__c} == null){
            <apex:variable var="monto" value="{!beneficio.Monto_Dolares__c}" />
        }
        else{     
            <apex:variable var="monto" value="{!beneficio.monto_estimado__c}" />     
        }
        <apex:column value="{!monto}"/>
        <apex:column value="{!beneficio.proposito__c}"/>
</apex:pageBlockTable>

 

Please can tell me what is wrong in mi code?

 

Regards,

Hi,

 

My name is Alejandra, i have a problem with display info in a table. The thing is:

 

I have two objects a) Contact (Salesforce object) and b) Beneficio (Custom object,  I personalize this object)

Both are relation directly, and this information can display in actually Contact Layout, i try change the format can display this information

 

I try to display all Beneficios have one contact whit this code

 

<apex:page standardController="Contact">
  <apex:pageBlock title="Contacts">
    <apex:pageBlockTable value="{!contact.Beneficio__c}" var="beneficio">

        <apex:column value="{!beneficio.proposito__c}"/>
        </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>


This is the error,

Error: Invalid field Beneficio for SObject Contact

 

I must be use other name or object name or alias? Please help me.

 

 

Hi developers,

I have my apex class deploy in my production instance and before I test this class and this was OK. When I try the implement my visualforce page I have this error "System.QueryException: List has more than 1 row for assignment to SObject" I prove this in my test instance and work fine. Please help me why is the problem.

This is my extension class

public class contactExtension {
    public contactExtension(ApexPages.StandardController contactController) {
       this.contact = (Contact)contactController.getRecord();
       idContact = contact.id;
    }
        
    public List<Beneficio__c> getBeneficiosBob()
    {
        Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
        idMonedabob = monedabob.id;
        x = 0;
        for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
            if (ben.monto_estimado__c == null){
                ben.monto_estimado__c = 0;
            }
            x = ben.monto_estimado__c + x;
        }
              
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob];
    }          
}

This is my visualforce page

<apex:page StandardController="Contact" extensions="contactExtension" >
  <apex:pageBlock title="Beneficios Bolivianos">
    <apex:pageBlockTable value="{!BeneficiosBob}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px,30px" rules="all">
        <apex:column value="{!beneficio.Name}"/>
        <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
        <apex:column value="{!beneficio.Moneda__c}"/>
        <apex:column value="{!beneficio.monto_estimado__c}" style="text-align:right;"/>
        <apex:column value="{!beneficio.proposito__c}"/>
        <apex:column value="{!beneficio.fecha_entrega__c}"/>
    </apex:pageBlockTable>
      <div class="resaltado">
         Total Bolivianos:       
         <apex:outputText value="{0,number,#,##0.00}" style="padding-left: 10px;">   
           <apex:param value="{!x}"/>
         </apex:outputText>
      </div>
  </apex:pageBlock>
</apex:page>

Regards,
Hi developers,

In this opportunity my question comes from about the test classes and coverage from this to apex classes

I have two classes, one is Apex Class and the other is the Test Class. My question is why my Apex Class is 0% coverage??? Run the test class and this finish OK. Please guide me how can I for coverage the code in my Apex Class?

I put the code from the two classes.

Thanks for the support 

APEX CLASS 

public class contactExtension {

    private final Contact contact;
    private string idContact;
    private final Moneda__c monedabob;
    private string idMonedabob;
    private final Moneda__c monedausd;
    private string idMonedausd;
    public decimal x {get;set;}
    public decimal totalUsd {get;set;}

    public contactExtension(ApexPages.StandardController contactController) {
       this.contact = (Contact)contactController.getRecord();
       idContact = contact.id;
    }
         
    public List<Beneficio__c> getBeneficiosBob()
    {
        Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
        idMonedabob = monedabob.id;
        x = 0;
        for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
            if (ben.monto_estimado__c == null){
                ben.monto_estimado__c = 0;
            }
            x = ben.monto_estimado__c + x;
        }
               
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob];
    }
             
    public List<Beneficio__c> getBeneficiosUsd()
    {
        Moneda__c monedaUsd = [select Name from Moneda__c where Moneda__c.name = 'Dolares'];
        idMonedausd = monedausd.id;
       
        totalUsd = 0;
        for (Beneficio__c ben : [select monto_dolares__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd]){
            totalUsd = ben.monto_dolares__c + totalUsd;
        }       
        return [select Catalogo_Beneficio__c, Name, Moneda__c, monto_dolares__c, proposito__c,fecha_entrega__c  from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedausd];
    }
}

TEST CLASS

@isTest public class ContactTest {          
        testMethod private static void getBeneficiosBob()
        {
            Account a= new Account(Name = 'Fundacion Inti Raymi');
            insert a;
           
            Operacion__c operacion= new Operacion__c(Name = 'Kori Chaca');
            insert operacion;
           
            Departamento__c departamento = new Departamento__c(Name = 'Oruro');
            insert departamento;
           
            Provincia__c provincia= new Provincia__c(Name = 'Cercado', Departamento__c = departamento.id);
            insert provincia;
           
            Municipio__c municipio= new Municipio__c(Name = 'Caracollo', Provincia__c = provincia.id);
            insert municipio;
           
            Comunidad__c comunidad= new Comunidad__c(Name = 'Iroco');
            insert comunidad;           
           
            Organizacion__c organizacion= new Organizacion__c (Name = 'Iroco');
            insert organizacion;
                                               
            Moneda__c monedabob = new Moneda__c(Name = 'Bolivianos', sigla__c = 'BOB');
            insert monedabob;
           
            Contact contacto = new Contact(Firstname= 'Alejandra', Lastname = 'Helguero', Carnet_Identidad__c = '22334455', Operacion__c = operacion.id, Departamento__c = departamento.id, Provincia__c = provincia.id, Municipio__c = municipio.id, Comunidad__c = comunidad.id, Organizacion__c = organizacion.id);
            insert contacto;

            Categoria_beneficio__c categoria = new Categoria_beneficio__c(Name = 'Produccion Ganadera');
            insert categoria;
           
            Subcategoria_beneficio__c subcategoria = new Subcategoria_beneficio__c(Name = 'Ganaderos', Categoria_Beneficio__c = categoria.id);
            insert subcategoria;
           
            Catalogo_beneficios__c tipo_beneficio= new Catalogo_beneficios__c(Name= 'Sanidad Animal', Nombre__c = 'Sanidad Animal', Categoria_Producto__c = categoria.id, Subcategoria_producto__c = subcategoria.id);
            insert tipo_beneficio;           
           
            for(Integer i = 0; i < 20; i++){
                Beneficio__c b = new Beneficio__c(Contacto__c = contacto.id, Moneda__c = monedabob.id, monto_estimado__c = 100.56, Catalogo_Beneficio__c = tipo_beneficio.id, fecha_entrega__c = Date.newInstance(2014, 06 ,20));
                insert b;
            }           
           
            Moneda__c monedabobS = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
            String idMonedabob = monedabobS.id;
           
            Decimal x = 0;
            for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :contacto.id and Moneda__c = :monedabob.id]){
                if (ben.monto_estimado__c == null){
                    x = ben.monto_estimado__c + x;
                }
            }
            Beneficio__c[] beneficios = [select Catalogo_Beneficio__c, Name, Moneda__c, monto_estimado__c, proposito__c,fecha_entrega__c from Beneficio__c where Contacto__c = :contacto.id and Moneda__c = :monedabob.id];
            System.assert(beneficios != null, 'Retorna valores');
        }
}

Hi everybody,

 

Can you help me please, i have this error in my apex class test, and I don't know for why

 

ERROR: Error de compilación: Invalid constructor name: contactExtension en la línea 3 columna 16

 

@isTest 

public class ContactTest {
public contactExtension(ApexPages.StandardController contactController) {
this.contact = (Contact)contactController.getRecord();
String idContact = contact.id;
}

static testmethod void myTestMethod1() {
Moneda__c monedabob = [select Name from Moneda__c where Moneda__c.name = 'Bolivianos'];
System.assert(monedabob != null);
String idMonedabob = monedabob.id;
Double x = 0;
for (Beneficio__c ben : [select monto_estimado__c from Beneficio__c where Contacto__c = :idContact and Moneda__c = :idMonedabob]){
x = ben.monto_estimado__c + x;
}

}
}

 

Regard,

 

Ale

Hello everybody,

 

Is possible display a blockTable in the if statement. Please tell me how can I do that?

 

Regards,

Hi,

 

I try to display this number with the following format 1.750,00 How can I do for obtain this?

The values for a apex:pageBlockTable, in the column the values show with this format, but in apex:outputText not work.      

 

Please help me, I try this:

 

<apex:outputText value="{0,number,#.##0,00}">    
    <apex:param value="{!totalUsd}"/>
</apex:outputText>

 

Regards,

Hello every body, I don't know why can't display the results in my visualforce page. The page don't show error only is empty

Please help me, I try to display the contacts in a family with their benefits

 

This is my visualforce page

 

<apex:page StandardController="Sayana__c" extensions="familiaExtension">
  <apex:pageBlock title="Beneficios">
  <apex:pageBlockTable value="{!BeneficiosTodos}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
     <apex:column value="{!beneficio.Contacto__c}"/>
     <apex:column value="{!beneficio.fecha_entrega__c}"/>
  </apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

and this is the apex class

 

public class familiaExtension {

    private final Sayana__c sayana;
    private string idSayana;
    private final Contact contacto;    
    private final Beneficio__c[] beneficios;

    public familiaExtension(ApexPages.StandardController sayanaController) {
       this.sayana = (Sayana__c)sayanaController.getRecord();
       idSayana = sayana.id;
    }

    public List<Beneficio__c> getBeneficiosTodos()
    {
       for(Contact contact : [SELECT  id, Name from Contact where Sayana__c = :idSayana]){
           Beneficio__c[] beneficios  = contact.Beneficios__r;
       }       
       return beneficios;
    }
}

 

 

Let me explain. I have an structure where I have three Objects, Contact, Benficio__c, Sayana__c. One Sayana__c have many Contacts, and one Contact have many Beneficios.

 

I try to display all contacts in a sayana__c and in each contact his beneficios. I have the following instructions in visualforce page.

 

<apex:pageBlockTable value="{!ContactosTodos}" var="contact" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
     <apex:column value="{!contact.Name}"/>
     <apex:pageBlockTable value="{!contact.Beneficio__r}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
         <apex:column value="{!beneficio.Name}"/>
         <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
         <apex:column value="{!beneficio.Moneda__c}"/>
         <apex:column value="{!beneficio.monto_estimado__c}"/>
         <apex:column value="{!beneficio.proposito__c}"/>
     </apex:pageBlockTable>
  </apex:pageBlockTable>

 

For last, let me know where I can see how is the names of relations in salesforce between objects?  I think that will help me so much.

 

Regards,

Hi my name is Alejandra,

 

I try to display in a column an variable that change with condition. The thing is that the variable set the last value, and not iterate with rows of table.

 

<apex:pageBlockTable value="{!contact.Beneficios__r}" var="beneficio" cellPadding="3" border="1" columnsWidth="50px,110px,60px,60px,230px" rules="all">
        <apex:column value="{!beneficio.Name}"/>
        <apex:column value="{!beneficio.Catalogo_Beneficio__c}"/>
        <apex:column value="{!beneficio.Moneda__c}"/>
        if({!beneficio.monto_estimado__c} == null){
            <apex:variable var="monto" value="{!beneficio.Monto_Dolares__c}" />
        }
        else{     
            <apex:variable var="monto" value="{!beneficio.monto_estimado__c}" />     
        }
        <apex:column value="{!monto}"/>
        <apex:column value="{!beneficio.proposito__c}"/>
</apex:pageBlockTable>

 

Please can tell me what is wrong in mi code?

 

Regards,

Hi,

 

My name is Alejandra, i have a problem with display info in a table. The thing is:

 

I have two objects a) Contact (Salesforce object) and b) Beneficio (Custom object,  I personalize this object)

Both are relation directly, and this information can display in actually Contact Layout, i try change the format can display this information

 

I try to display all Beneficios have one contact whit this code

 

<apex:page standardController="Contact">
  <apex:pageBlock title="Contacts">
    <apex:pageBlockTable value="{!contact.Beneficio__c}" var="beneficio">

        <apex:column value="{!beneficio.proposito__c}"/>
        </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>


This is the error,

Error: Invalid field Beneficio for SObject Contact

 

I must be use other name or object name or alias? Please help me.