You need to sign in to do that
Don't have an account?
Bulk XML creation
we currently create xmls through and send them through a web service to our back end systems. This was only done by users but now the volume of these ahas increased and there is the desire to have them work in bulk.
I dont know if i am doing the trigger wrong or the class wrong that actually generates the xml.
Trigger
trigger SendContact on Contact (after insert, after update) {
CreateContactXML cxml = new CreateContactXML();
for (Integer i = 0; i < Trigger.new.size(); i++) { //for all records
cxml.CreateXMLFile(Trigger.new[i].id); }
Class
public class CreateContactXML {
public List<Contact> ContactDetails;
public List<XML_Path__c> PathDetails;
public XML_Document_Helper.XML_Sheet xmlDoc{get;set;}
XML_Document_Helper helper = new XML_Document_Helper();
public string xmltran;
public string attachmentid;
String orgId = UserInfo.getOrganizationId();
public void CreateXMLFile(string contact_id) { //List<Contact> contacts = new list<contact>();
For( Contact c1 : [SELECT Id, title from Contact a where id = :Contact_id]){ ContactDetails.add(c1);}
Map<id, contact> con = new Map<id, contact>([select contact.Id, contact.Lastname from Contact c where Id in : contactdetails]);
IT WORKS IF I USE THE SOQL STATEMENTS BELOW BUT DOES NOT WORK IN BATCH; IF I TRY TO ADD TO THE LIST I STILL GET NULL VALUES BELOW
//ContactDetails = [SELECT Contact.Id from Contact a where id = :Contact_id];
//PathDetails = [SELECT XML_Path__c.Path__c from XML_Path__c where recordID__c = :ContactDetails[0].RecordTypeID];
//creating the XML
string newxml = createXMLDoc();
//attaching the XML to XML_Transaction object
attachmentid = helper.AttachContactXML(newxml,contact_id);
// sending out the XML
// sendoutXML(attachmentid);
}
public string CreateXmlDoc(){
List<XML_Document_Helper.XmlAttr> currCoverAttr = new List<XML_Document_Helper.XmlAttr>();
xmlDoc = new XML_Document_Helper.XML_Sheet();
//for (integer r=0; r< ContactDetails.size(); ++r){
XML_Document_Helper.XmlAttr xmlAttr= new XML_Document_Helper.XmlAttr();
xmlAttr.attr = 'OrgID';
xmlAttr.value = orgid;
currCoverAttr.add(xmlAttr);
xmlAttr= new XML_Document_Helper.XmlAttr();
xmlAttr.attr = 'SFObject';
xmlAttr.value = 'Contact';
currCoverAttr.add(xmlAttr);
xmlAttr= new XML_Document_Helper.XmlAttr();
xmlAttr.attr = 'Id';
xmlAttr.value = ContactDetails[0].id;
currCoverAttr.add(xmlAttr);