You need to sign in to do that
Don't have an account?

Put values of Opportunity List into a custom Object List
Hello everyone,
I've got a Classe named 'ManageUser". In this class, a method extract all opportunities for users.
I've got an other Class named 'ManageFAST". In this class, I need to copy the values of the Opportunity List.
And I don't know how to do it.
Here is my code.
ManageUser :
ManageFAST :
Thanks
I've got a Classe named 'ManageUser". In this class, a method extract all opportunities for users.
I've got an other Class named 'ManageFAST". In this class, I need to copy the values of the Opportunity List.
And I don't know how to do it.
Here is my code.
ManageUser :
public Boolean loadOpportunityList(Date quarter){ String query = ManageOpp.OPP_QUERY; query += ' WHERE Owner.Id =: id'; if(quarter != null){ query += ' AND CloseDate >=: quarter'; } List<Opportunity> oppList = Database.query(query); if(oppList.isEmpty()){ return false; } myOppList = new List<ManageOpp>(); for(Opportunity opp : oppList){ myOppList.add(new ManageOpp(opp)); } return true; } public Boolean loadOpportunityList(){ return loadOpportunityList(null); } public List<ManageOpp> getOpportunityList(){ return this.myOppList; }
ManageFAST :
public List<FAST__c> fast{get;set;} private List<FAST_OPP__c> fastOppList; private List<ManageOpp> manageOppList{get;set;} private manageUser oppUser; public Date quarter; public ManageFAST() { fast = new List<FAST__c>(); oppUser = new ManageUser(); } public void loadFAST(){ List<FAST__c> fast = new List<FAST__c>(); fast = [SELECT Id, Sales_ID__c, Forecast_Manager_ID__c, Quarter_Date__c, Commit_Manager__c, Transactionnal_Amount_Forecast_Exit__c, Transactionnal_Amount_Optimistic__c, Transactionnal_Amount_Pessimistic__c FROM FAST__c]; } public void initFASTOppList(){ oppUser.load(UserInfo.getUserId()); //quarter = Date.newInstance(1960, 2, 17); oppUser.loadOpportunityList(quarter); for(FAST_OPP__c fo : oppUser.getOpportunityList()) { } }
Thanks
Your oppUser.getOpportunityList() returns a List<ManageOpp>, not a List<FAST_OPP__c>, so, if you are going to iterate through it, you must do it in the next way:
Then I understand that your ManageOpp class should have a variable in which the opportunity that you have passed to its constructor is stored? Then you can do something like:
Ok I understand now. Thank you :)
I've a trouble with my List<ManageOpp>, I want to put the received values of this List into an other List, but it's not the same type of List. How I can do it ?
Regards
But now I'm stuck to compare two List. I have a List wich get the Opportunity of a User, and an other List with Opportunity in Object FAST_OPP.
Error : Method does not exist or incorrect signature: [List<FAST_Opp__c>].contains(Id)
Why I can't compare the Id ?
Regards
new Set<FAST_Opp__c>(fastOppList).contains(mo.getOppId());
Regards