function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AMIT KUMAR 73AMIT KUMAR 73 

Web Service callout from a custom button

Hi,

I am trying to achieve one functionality:

1. Creating a custom button on "CASE" object say "Submit To Web Service"
2. Creating a checkbok field to select one or more case for a certain account.
3. Based on the selection (point#2) it should send out the case related information to some third part web service using Apex call out.

Is this possible to build this logic in salesforce?
CJagannathCJagannath
Yes it is absolutely possible in Salesforce. Based on customer infrastructure and your requirements, appropriate outbound integration options should be followed.  Please follow the link on this context.
http://www.salesforce.com/us/developer/docs/integration_patterns/integration_patterns_and_practices.pdf

Thanks,
Jagannath
asish1989asish1989
Yeah It is possible in salesforce. Create a button on Case Object,You can give conent source as URL or Javascript based on the complexcity and append required parameter which you want to send, to the end point url of external system.

Here I am sharing some code regarding how to integrate conga composer in your org.

Button code where content source is URL
https://www.appextremes.com/apps/Conga/PointMerge.aspx?SessionId={!API.Session_ID}
   &ServerUrl={!API.Partner_Server_URL_80}
   &Id={!Credit_Note__c.Id} //object id where button is present
   &DefaultPDF=1
   &PartnerCode=0015000000Yd8nM // optionals
  &EmailReplyToId{!User.Id}
  &EmailToId={!Credit_Note__c.Billing_ContactId__c}//to whom emil is going
  &EmailRelatedToId={!Credit_Note__c.Id}//object id where button is present
  &TemplateId=a0mb0000000KYO0 // conga templae id which you have created
  &QueryID=[CreditLines]a0nb0000000zgUE

Bold letter is end ponit url.

If you want use Javascript then you need to call this Url in javascript. window.open(url, blank).

For more reference
http://salesforceworld4u.blogspot.in/2013/08/generating-pdf-using-conga-composer.html
AMIT KUMAR 73AMIT KUMAR 73
Hi Ashish,

Thanks for the detailed response. I just try to create the scenario with content source as "Visual force Page" insted of "URL".

User-added image

Content drop down field is required, but providing no options to select values.
Where we need to define the content? Just gone through the help section but couln't able to figure out.
Could you please help me on this!

asish1989asish1989
Hi

Create a vf page having standard controller as Case and an extension class.

In your extension class write http method for external callout.Here I am sharing some sample code

Http httpObject = new Http();
        HttpRequest httpRequest = new HttpRequest();
        HttpResponse httpResponse;
      
        String username = gateway.Merchant_ID__c;
        String password = gateway.Security_Key__c;
        system.debug('username' +username);
        system.debug('password' +password);
      
        Blob headerValue = blob.valueOf(username + ':' + password);
        string authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
      
        httpRequest.setHeader('Authorization', authorizationHeader);
        httpRequest.setHeader('Content-type', 'text/xml');
      
        httpRequest.setEndpoint(sHttpEndPoint);
        httpRequest.setMethod('POST');
        httpRequest.setBody(xmlBody);    
  httpResponse = httpObject.send(httpRequest);
  sRawHttpResponse = httpResponse.getBody();
  Dom.Document doc = httpResponse.getBodyDocument();
  Dom.XMLNode rootElement = doc.getRootElement();
  getElements(rootElement);

  map<string, string> mapOfKeyValue = new map<string, string>();  

  private void getElements(DOM.XMLNode node) {
    if(node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
   System.debug('node name & text is ' + node.getName() + '::' + node.getText());
   if(node.getText().trim() != '') {
    mapOfKeyValue.put(node.getName(), node.getText().trim());
   }

   for(Dom.XMLNode child : node.getChildElements()) {
    getElements(child);
   }
    }
  }

important :

If this is what you where looking for then please mark it as a solution for others benefits.


Thank You