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
balaji manikandanbalaji manikandan 

How to attach a record details using Conga Composer through apex?

I need to attach the details of the record to as a Document to same record using Conga Composer through apex call out Conga.
https://support.getconga.com/Conga_Composer/Advanced_Composer_Solutions/Composer_Tips_and_Tricks/How_to_Call_Conga_Composer_from_Apex i have refered the above link but its not working for me , i am not sure wheather i followed it correctly or not .
Best Answer chosen by balaji manikandan
balaji manikandanbalaji manikandan
String sessId = UserInfo.getSessionId();
    String servUrl = Url.getSalesforceBaseUrl().toExternalForm()+'/services/Soap/u/29.0/'+UserInfo.getOrganizationId();

    String url2 = 'https://composer.congamerge.com/composer8/index.html'+
                          '?sessionId='+sessId+
                          '&serverUrl='+EncodingUtil.urlEncode(servUrl, 'UTF-8')+
                          '&id=00128000007hiuE'+
                          '&TemplateId=a0L0K00 000FL8hN'+
                          '&SC0=1'+
                          '&SC1=Attachments'+
                          '&FP0=1'+
                          '&DS7=1'+
                          '&DefaultPDF=1&APIMode=1';

    System.debug(url2);

    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint(url2);
    req.setMethod('GET');
    req.setTimeout(60000);

// Send the request, and return a response
    HttpResponse res = http.send(req);

    System.debug(res);

    system.debug('::::'+ res.getStatus() + ' => ' + res.getBody());

    Attachment att = [Select Name, Body From Attachment Where id =: res.getBody()];
    system.debug(att.Body);

change the Id with the Record id for which u want to work on and change the template id with your Conga composer template id