0

can someone help me with this operation with lists? I have two lists, one is a custom object and the other is :

public class OppNegocioTemp {
    public Double Demanda_Compra {get;set;}
    public Double Oferta_Venda {get;set;}
    public String VariedadeNome {get;set;}
    public String idopp {get;set;}
    
    public OppNegocioTemp(Oportunidade_de_Negocios__c oppNeg){
        Demanda_Compra=oppNeg.Demanda_Compra__c;
        Oferta_Venda=oppNeg.Oferta_Venda__c;
        VariedadeNome=oppNeg.Variedade__r.Name;
        idopp=oppNeg.Id;
    }
}

I don't know the name given when creating this type of lists, what I did so far was to receive the data in a vfp and save it in this temporary list, and now I send the data from this temporary list to the object (save in the database)

Controller

public List<OppNegocioTemp>getOppNegocios(){
        if(oppNegocios==null){
            oppNegocios=[Select Id, Variedade__c,Variedade__r.Name, Oferta_Venda__c, LastModifiedDate, Licenciado__c, Safra__c,Demanda_Compra__c, Conta__c  
                         FROM Oportunidade_de_Negocios__c WHERE Licenciado__c =: idlicenciado AND Safra__c =: safraActual ORDER BY LastModifiedDate DESC ];
        }
        for(Oportunidade_de_Negocios__c i:oppNegocios ){
            listTempOppNegocios.add(new OppNegocioTemp(i) );
        }
        
        for(OppNegocioTemp i:listTempOppNegocios){
            oppNegocios.add(listTempOppNegocios(i));
        }
        
        return listTempOppNegocios;
    }

in short I did a select for popular oppNegocios then I sent the data from oppNegocios to listTempOppNegocios and now I want to do the opposite, send the data from listTempOppNegocios for oppNegocios but I must be wrong in the syntax... I keep getting the following error:

 Method does not exist or incorrect signature: void listTempOppNegocios(OppNegocioTemp) from the type aSiteOppNegociosController

thank you who can help...

1
  • Full controller code (at least all bits relevant for this question) would be useful
    – metasync
    May 9, 2022 at 1:51

1 Answer 1

1

Instead of

...
        for(OppNegocioTemp i:listTempOppNegocios){
            oppNegocios.add(listTempOppNegocios(i));
        }
...

you need to have (notice that you need to call get on list to get an element or use array accessor [] notation instead of method call () notation)

...
        for(OppNegocioTemp i:listTempOppNegocios){
            oppNegocios.add(listTempOppNegocios.get(i));
        }
...

With that said, you could also achieve what you are trying to as follows without you looping.

oppNegocios.addAll(listTempOppNegocios)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .