You need to sign in to do that
Don't have an account?
Maf_007
Updating fields from Map
Hi,
I am parsing an xml file and putting the value in a Map. Now I would like to update an object with the values in the map But I am getting following error:
Initial term of field expression must be a concrete sobject: List <String>
My xml parser is below:
private Map<String,list<string>> parsexml(DOM.XMLNode node){ list<String> mslist = new list<string>(); Map<String,list<string>> msmap = new Map<String,list<String>>{}; //system.debug('Node:::'+node); String annualsave; String costsaving; String annualscore; String MSId; String result; for(Dom.XMLNode child : node.getChildElements()) { //system.debug('child:::'+child); for(DOM.XMLNode node1:child.getChildElements()){ system.debug('child of child::'+node1); if(node1.getName()=='Id'){ MSId = node1.getText().trim(); system.debug(MSId); } else if(node1.getName()=='Annual-Save'){ annualcarbonsave = node1.getText().trim(); result = annualsave; system.debug(annualsave); mslist.add(annualsave); } else if(node1.getName()=='Cost-Save'){ costsave = node1.getText().trim(); system.debug(costsave); mslist.add(costsave); } else if(node1.getName()=='Annual-Score'){ annualscore = node1.getText().trim(); system.debug(costscore); mslist.add(annualscore); } msmap.put(MSId,mslist); } } return msmap; }
And Here I am relating this to the salesforce object:
Map<String,list<string>> msmap = new Map<String,list<String>>{}; msmap = parsexml(root); List<Me__c> Ms = [select id, annual_save__c, cost_save__c from Me__c where id in: msmap.keySet()]; for(Me__c m: Ms){ m.cost_save__c = msmap.get(m.id).costsave; }
Could you please guide me in right direction here.
Thanks,