• David Bloomy Bloom
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi, I have the below code working in my Sandbox. I need help writiing the test code to move my code to production. I am not an apex coder so I am looking for a kind person to write the test code for me.

You help would be grately appreciated

Thanks in advance

David

TRIGGER

trigger Conga_First_Email on Sabre_Hotels__c (after insert, after update) {
if(Trigger.new.size() == 1) { // NOTE: Conga does not allow batch requests. They will terminate your account.
     if(Trigger.new[0].First_Email_Sent__c && (Trigger.old == null || !Trigger.old[0].First_Email_Sent__c)) { // "Rising Edge" trigger
            CongaCallout.execute(UserInfo.getSessionId(), Trigger.new[0].Id);
     }
}
}

CLASS

public with sharing class CongaCallout {
    @future(callout=true)
    public static void execute(String sessionId, Id recordId) {
        Sabre_Hotels__c record = [SELECT Id, Name, Hotel_Email_Address__c FROM Sabre_Hotels__c WHERE Id = :recordId];
        PageReference ref = new PageReference('https://www.appextremes.com/apps/Conga/PM.aspx');
        ref.getParameters().putAll(
            new Map<String, String> {
             'sessionId' => sessionId,
             'serverUrl' => Url.getSalesforceBaseUrl().toExternalForm()+'/services/Soap/u/31.0/'+UserInfo.getOrganizationId(),
                'id' => recordId,
             'ReportId' => '00O9000000793dm?pv0='+record.Name,
             'EmailToID' => '003N000000DQGs4',
             'EmailAdditionalTo' => record.Hotel_Email_Address__c,
             'CETID' => 'a0JN0000002GElB',
             'TemplateId' => 'a0LN00000015SaB',
             'AC0' => '1',
             'SCO' => '1',
             'DS7' => '1',
             'APIMode' => '1',
             'APIMode' => '12'
            }
        );
        Http binding = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(ref.getUrl());
        req.setMethod('GET');
        req.setTimeout(120000);
      
        HttpResponse res = binding.send(req);
        if(res.getStatusCode()==200) {
            // Everything was okay
        } else {
            // An error occurred here
        }
        System.debug(LoggingLevel.ERROR, res);
}
}
Hi, I am trying to execute the below when I change the status of First_Email_Sent__c from False to True. When this changes I need to fire an http request. Below is what I have managed to find but I am unsure how to check the status has changed and if the http request is correct.

Thanks in advance
David

trigger Run_custom_button on Sabre_Hotels__c (after update) {
   
    if record.First_Email_Sent__c == true {
        url = "https://composer.congamerge.com
   ?sessionId={!API.Session_ID}
   &serverUrl={!API.Partner_Server_URL_290}
   &id={!Sabre_Hotels__c.Id}
   &ReportId=00O900000079wd3?pv0={!Sabre_Hotels__c.Name}
   &EmailToID=0039000000B4Z9N
   &EmailAdditionalTo={!Sabre_Hotels__c.Hotel_Email_Address__c}
   &CETID=a0J9000000U4NUn
   &TemplateId=a0L9000000DB1Te
   &AC0=1
   &SC0=1
   &_DS7=9
   &DS7=1
   &QMode=3";
       
        HttpRequest req = new HttpRequest();
      req.setEndpoint(url);
      req.setMethod('GET');
       
        Http http = new Http();
      HTTPResponse res = http.send(req);
    }
}
Hi, I am looking for assistance to write an apex trigger to execute a cusom button on my custom object when I change the state of a check box (via apex loader) from false to true.

My custom field is First_Email_Sent__c and my custom button is Conga_First_Email My custom object is called Sabre_Hotels (Sabre_Hotels__c)

thanks you in advance for any assistance.

David
Hi, I am looking for assistance to write an apex trigger to execute a cusom button on my custom object when I change the state of a check box (via apex loader) from false to true.

My custom field is First_Email_Sent__c and my custom button is Conga_First_Email My custom object is called Sabre_Hotels (Sabre_Hotels__c)

thanks you in advance for any assistance.

David
Hi, I have the below code working in my Sandbox. I need help writiing the test code to move my code to production. I am not an apex coder so I am looking for a kind person to write the test code for me.

You help would be grately appreciated

Thanks in advance

David

TRIGGER

trigger Conga_First_Email on Sabre_Hotels__c (after insert, after update) {
if(Trigger.new.size() == 1) { // NOTE: Conga does not allow batch requests. They will terminate your account.
     if(Trigger.new[0].First_Email_Sent__c && (Trigger.old == null || !Trigger.old[0].First_Email_Sent__c)) { // "Rising Edge" trigger
            CongaCallout.execute(UserInfo.getSessionId(), Trigger.new[0].Id);
     }
}
}

CLASS

public with sharing class CongaCallout {
    @future(callout=true)
    public static void execute(String sessionId, Id recordId) {
        Sabre_Hotels__c record = [SELECT Id, Name, Hotel_Email_Address__c FROM Sabre_Hotels__c WHERE Id = :recordId];
        PageReference ref = new PageReference('https://www.appextremes.com/apps/Conga/PM.aspx');
        ref.getParameters().putAll(
            new Map<String, String> {
             'sessionId' => sessionId,
             'serverUrl' => Url.getSalesforceBaseUrl().toExternalForm()+'/services/Soap/u/31.0/'+UserInfo.getOrganizationId(),
                'id' => recordId,
             'ReportId' => '00O9000000793dm?pv0='+record.Name,
             'EmailToID' => '003N000000DQGs4',
             'EmailAdditionalTo' => record.Hotel_Email_Address__c,
             'CETID' => 'a0JN0000002GElB',
             'TemplateId' => 'a0LN00000015SaB',
             'AC0' => '1',
             'SCO' => '1',
             'DS7' => '1',
             'APIMode' => '1',
             'APIMode' => '12'
            }
        );
        Http binding = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(ref.getUrl());
        req.setMethod('GET');
        req.setTimeout(120000);
      
        HttpResponse res = binding.send(req);
        if(res.getStatusCode()==200) {
            // Everything was okay
        } else {
            // An error occurred here
        }
        System.debug(LoggingLevel.ERROR, res);
}
}
Hi, I am trying to execute the below when I change the status of First_Email_Sent__c from False to True. When this changes I need to fire an http request. Below is what I have managed to find but I am unsure how to check the status has changed and if the http request is correct.

Thanks in advance
David

trigger Run_custom_button on Sabre_Hotels__c (after update) {
   
    if record.First_Email_Sent__c == true {
        url = "https://composer.congamerge.com
   ?sessionId={!API.Session_ID}
   &serverUrl={!API.Partner_Server_URL_290}
   &id={!Sabre_Hotels__c.Id}
   &ReportId=00O900000079wd3?pv0={!Sabre_Hotels__c.Name}
   &EmailToID=0039000000B4Z9N
   &EmailAdditionalTo={!Sabre_Hotels__c.Hotel_Email_Address__c}
   &CETID=a0J9000000U4NUn
   &TemplateId=a0L9000000DB1Te
   &AC0=1
   &SC0=1
   &_DS7=9
   &DS7=1
   &QMode=3";
       
        HttpRequest req = new HttpRequest();
      req.setEndpoint(url);
      req.setMethod('GET');
       
        Http http = new Http();
      HTTPResponse res = http.send(req);
    }
}
Hi, I am looking for assistance to write an apex trigger to execute a cusom button on my custom object when I change the state of a check box (via apex loader) from false to true.

My custom field is First_Email_Sent__c and my custom button is Conga_First_Email My custom object is called Sabre_Hotels (Sabre_Hotels__c)

thanks you in advance for any assistance.

David