• bfeather19
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
 

I dont know how to make the variables from CreateXMLFile(Contact[] updatedContacts, Map<ID, Contact> ContactMap) available in the createxml string below it.  It was orginally done with public lists but now I have to make this process work for bulk and I cant seem to get there.

 

any help???

 

 

public with sharing class CreateContactXML {
 

    private boolean m_isExecuting = false;
    private integer BatchSize = 0;
    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 CreateContactXML(boolean isExecuting, integer size){
       m_isExecuting = isExecuting;
       BatchSize = size;
       }
       
public void CreateXMLFile(Contact[] updatedContacts, Map<ID, Contact> ContactMap){

for( Contact c :updatedContacts){
   
 
        //creating the XML
        string newxml = createXMLDoc();
        
        //attaching the XML to XML_Transaction object
        attachmentid = helper.AttachContactXML(newxml,c.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();
      
      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);

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);

what is a good work around for having multiple owners or something like a sales team on contacts.  I dont want to push duplicate contacts into the system but multiple sales people may have that contact in there list of people to note as theirs.

 

When we hire/fire a sales rep we like to be able to say the following contacts were the ones from the sales rep before you.

 

any ideas it is becoming a growing problem in trying to keep the contacts database clean

Hello all very new at this so doing alot of frustrating guessing and checking...

 

I am looking for the best way to use saleforce to create a selection screen for an external report.

 

I need the user to supply a few fields report type sales rep name and press submit.  at that time the formula fields will populate and the results of those formula fields needs to be compiled into a url:

 

by supplying the user lookup name  the formula knows the office location of the user which then builds the url for them to go to:

 

http://intranet/{useroffice}

 

 

Hi,

for my project , i need to clone some records but with the possibility for the user to change some fields (reset the status, ...). So i don't use the standard Clone button.

In my Apex class, I use the clone() method and then insert :

 

 

request = [select Id, Circuit__c from MyObject where id = :request.id];
clonedRequest = request.clone(false);
insert clonedRequest;
return new PageReference('/'+clonedRequest.id+'/e?retURL=%2F'+clonedRequest.id);

 

The problem i have is in this case, this code has created a new record ID, even if the user cancels it (due to the insert).
Is it possible not to insert the new record, but to see a temporary version which is really created only when clicking on the Save button (as the standard Clone works) ?
Thanks for your help
Ced

 

  • March 11, 2011
  • Like
  • 0