0
public class temp{
public list<CnP_Transaction__c> transactions{get;set;}
public CheckContactController chk{get;set;}
puublic temp(){
    chk = new CheckContactController();
}
    public void savetemp(){
    list<Temporary_contact__c> selectedval = [select id,First_Name__c,Last_Name__c,Email__c,Installment__c,Check_temp__c,Map_Contact__c,OrderNumber__c,Recurring__c,Xmldata__c from Temporary_contact__c where Id IN :seltemp] ;    

  // some code here
     insert Transactions; // in transactions say suppose 2 recods are inserted
//In selectedval say suppose 2 Records are coming            
    for(integer i=0; i<selectedval.size(); i++){  
    xmldata = selectedval[i].Xmldata__c;
      oppitems = chk.OpportunityItems(xmldata,transactions,recs,xmlvalue,con.firstname+''+con.lastname);   
    }if(!oppitems.isEmpty()) insert oppitems;
    }
}

Now My problem here is for the 1st Record of selectedval I'm getting two transactions in oppitems.But I need to get the first record of selectedval with only 1st Record in transactions and the same way as second record of selectedval with only 2nd Record in transactions.

I can't write
oppitems=chk.OpportunityItems(xmldata,transactions,recs,xmlvalue,con.firstname+''+con.lastname); outside the for loop as I'm using xmldata in it

If I use oppitems=chk.OpportunityItems(xmldata,transactions[i],recs,xmlvalue,con.firstname+''+con.lastname);.It is throwing me an error because transactions should be a list but here transactions[i] is a string

Stucked here.Any help on this pls.

0

If you cannot change CheckContactController, may be use a temporary list?

for(integer i=0; i<selectedval.size(); i++){  
    list<CnP_Transaction__c> tmpTransactions = new List<CnP_Transaction__c>();
    tmpTransactions.add(transactions[i]);
    xmldata = selectedval[i].Xmldata__c;
    oppitems = chk.OpportunityItems(xmldata,tmpTransactions,recs,xmlvalue,con.firstname+''+con.lastname);   
}
if(!oppitems.isEmpty()) insert oppitems;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.