• ManojKumar Muthu
  • NEWBIE
  • 149 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 32
    Questions
  • 26
    Replies
Can someone help with test call for the below code,

Public with sharing class Restcall
{
@future(callout=true)
public static  void callwebservice(Id Accid, String name, String email, String title)

{
HTTP auth = new HTTP()    ;
HTTPRequest r = new HTTPRequest();
r.setHeader('Content-Type','application/json');
String username = 'name@yyy.com';
String password = 'yyy@123';
String loginresponse = 'null';
String Token = 'null';
r.setEndpoint('https://example/v1/users/login');
r.setMethod('POST');
r.setBody('{"email":"name@yyy.com","password":"yyy@123"}');
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(r);

JSONParser parser = JSON.createParser(authresp.getBody());
System.debug('parser '+ parser);
//Token = parser.getText();
While (parser.nextToken() != null){
if((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'access_token') )
{
 String fieldvalue= parser.getText();
 parser.nextToken();
 token = parser.getText();
  

   System.debug('parser.getCurrentName() => '+ parser.getCurrentName());
   System.debug('parser.getText() => '+ parser.getText());
   
   System.debug('Token Name=> '+ fieldvalue);
      System.debug('Token Value  => '+ token );
   
   }
     
}
      

HTTP auth1 = new HTTP()    ;
HTTPRequest r1 = new HTTPRequest();
r1.setHeader('Content-Type','application/json');
r1.setHeader('Authorization', 'Bearer ' +Token);
r1.setEndpoint('https://example/v1/accounts/updateaccountdetails');
r1.setMethod('POST');  
system.debug('Account ID'+ accid);
system.debug('LEVEL 2 Name'+ name);
system.debug('level_2_email'+ email);
system.debug('level_2_title'+ title);
Account_Case_Escalation__c jsonb = new Account_Case_Escalation__c();
r1.setBody('{"account_id":"'+accid+'", "level_2_name":"'+name+'", "level_2_email":"'+email+'", "level_2_title":"'+title+'"}');
HTTPResponse authresp1=new HttpResponse();
authresp1 = auth1.send(r1);
system.debug('Statuscode Expected'+ authresp1.getStatusCode());
system.debug('Body expected' + authresp1.getBody());
 }
}

Thanks in advance.
I got stuck here, can someone help to slove this error,
below my code,
Trigger:
trigger Level2Update on Account_Case_Escalation__c (after update) {

for(Account_Case_Escalation__c ACE: trigger.new)
{
util.callwebservice(ace.Account__c, ace.Level_2_Name__c, ace.Level_2_Email__c, ace.L2_Title__c);
system.debug('Account Case account  '+ ace.Account__c);
system.debug('Account Case email  '+ ace.Level_2_Email__c);
system.debug('Account Case name  '+ ace.Level_2_Name__c);
system.debug('Account Case Title  '+ ace.L2_Title__c);


}

}

Apex Class:

public with sharing class util
{
@future(callout=true)
public static  void callwebservice(Id Accid, String name, String email, String title)

{
HTTP auth = new HTTP()    ;
//List<contact> acc = [Select Id, Name from Account Where Id IN :recordIds];
//String Body = "Accountid":cid + "id":aid;

HTTPRequest r = new HTTPRequest();
r.setHeader('Content-Type','application/json');
String username = 'appviewxsupport2@yopmail.com';
String password = 'Appviewx@123';

Blob headerValue = Blob.valueOf(username+ ':' + password );
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
r.setHeader('Authorization', authorizationHeader);
r.setEndpoint('https://salesforceintegrationstaging.payoda.com/api/web/v1/accounts/updateaccountdetails');
r.setMethod('POST');
r.setBody('{"account_id":"accid","level_2_name":"name","level_2_email":"email","level_2_title":"title"}');
//r.setBody(body);   
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(r);
system.debug('Statuscode Expected'+ authresp.getStatusCode());
System.debug('Body expected' + authresp.getBody());
}
}

When I run the above code below the error i facing,
Error: System.HttpResponse[Status=Unauthorized, StatusCode=401

TIA
 
Hi there,

I am new to the integration could someone help me with the below requirment,

We have integrated salesforce with one of our website and used rest api for all call.
Now from the website they had shared their api so that I have to update the details in the webpage when some modification happens in Salesfroce.
For Instant: I had change the account owner for "India" accounts then I have to call the give third party api and update the same in the website.
I have already set up the remote site.

TIA 

HI there,
We have webpage where our clients will create a case along with that will attach a file of size more than 1GB, 

In Lightinig the larger files are getting uploaded in Contentdocument,

Can anyone help me how to decode a file upload the same in content to the respective case?
TIA



 

HI there,

Below my code was working fine, but suddenly pass an error, when I try to attach a document,

Custom API for Case Attachment,
@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID){

        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        if(Test.isRunningTest()){
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        //String doc=EncodingUtil.Base64Encode(req.requestBody);
        }
        
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = ParentID;
                
        insert a;
        
        
    }
}

Below the resultUser-added imageCan someone help with this asap.
Hi there,

I have field name "Priority" with values 1,2,3,4.

if(String.isNotBlank(priority))
    {    
       str+=' AND Priority = \''+ priority+'\'';
    }
As of now I can able to pass only one value at a time is there a way to pass like this "Priority":"1,2"
Hi there,
I got stuck here, out of 13 filter criteria I have achive 11 and rest I am stuggling to sorting out,

Below my code, here I am trying to achive is, 
In the Priority field, which is single pick list field where I have pass more than one value
For Example: Priority: 1 & 2
Secondly in the CreatedDate field I have to pass a date range
For Example: Createddate= 2018-12-12 to 201-1-1

Apex Class,
@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpPost
    global static List<Case> dopostCase(String CreateDate,String Owneremail, String Bugis, String Version, String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String Product, String Name, String OwnerName) {
    List<Case> caseList = new List<Case>();
    String str='Select id, CreatedDate, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed, Product_Type__c, ContactName__c, GS_Account__c from Case where accountid =\''+ accountid +'\'';
    
    if(String.isNotBlank(Owneremail))
    {
       str+=' AND OwneEmail__c=\''+ Owneremail+'\'';
    }
    if(String.isNotBlank(Bugis))
    {
       str+=' AND BugIs__c=\''+ Bugis+'\'';
    }
    if(String.isNotBlank(Version))
    {
       str+=' AND Version__c=\''+ Version+'\'';
    }
    
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
    // if(String.isNotBlank(priority))
   // {
   //    str+=' AND Priority=\''+ priority+'\'';
   // }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status =\''+ status+'\'';
    }
    
    if(String.isNotBlank(CStatus))
    {
       str+=' AND CStatus__c=\''+ CStatus+'\'';
    }
    if(String.isNotBlank(Product))
    {
       str+=' AND Product_Type__c=\''+ Product+'\'';
    }
    if(String.isNotBlank(Name))
    {
       str+=' AND ContactName__c Like \'%'+ Name+'%\'';
    }
    if(String.isNotBlank(OwnerName))
    {
       str+=' AND Case_Owner_Name__c Like \'%'+ OwnerName+'%\'';
    }
    
    if(String.isNotBlank(priority))
    {
    for(string pstring : priority.split(',')){
       str+=' AND Priority=\''+ pstring +'\'';
     }

}
 if(String.isNotBlank(CreateDate))
    {
       str+=' AND CreatedDate = \''+ CreateDate+'\'';
    }
    if(String.isNotBlank(Keyword))
   {
      str+=' AND (Subject Like\'%'+ Keyword+'%\'';
      str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
   }  
   System.debug(str);
    caseList=Database.query(str);
    return caseList;
}
}
 
Can someone help with this,
TIA
Hi there,

I have 3 pick list field in "Opportunity Object" base on the I selection a value shoud get arrived in another field name"ARR_value__c"
1. Opportunity_Type__c: New License, License Renewal, PS-Managed Services, AMC, PS
2. License_Type__c: Annual, Perpetual, One Time
3. Payment_Terms__c: Upfront, Annual, Monthly, Milestone
 and the condition is
If(Opportunity_Type__c='New License' && License_Type__c='Annual' && Payment_Terms__c='Upfront' )
{
ARR_value__c = (Bookings__c/License_period__c)*12
}
else if(Opportunity_Type__c='New License' && License_Type__c='Perpetual' && Payment_Terms__c='Upfront' )
{
ARR_value__c = Bookings__c* 20%
}
else if(Opportunity_Type__c='New License' && License_Type__c='One Time' && Payment_Terms__c='Monthly' )
{
ARR_value__c = (Bookings__c/License_period__c)*12
}

note: Bookings__c and License_period__c are number field

TIA



 
 
Hi there,

Can someone help with test class for below two Apex class??

@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID ){
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String doc=EncodingUtil.Base64Encode(req.requestBody);
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = 'Id';
                
        insert a;
        
    }
}

and-------------------------------------------------------------------------------------------------------

@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpPost
    global static List<Case> dopostCase(String Owneremail, String Bugis, String Version, String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword) {
    List<Case> caseList = new List<Case>();
    String str='Select id, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed from Case where accountid =\''+ accountid +'\'';
    
    if(String.isNotBlank(Owneremail))
    {
       str+=' AND OwneEmail__c=\''+ Owneremail+'\'';
    }
    if(String.isNotBlank(Bugis))
    {
       str+=' AND BugIs__c=\''+ Bugis+'\'';
    }
    if(String.isNotBlank(Version))
    {
       str+=' AND Version__c=\''+ Version+'\'';
    }
    
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
     if(String.isNotBlank(priority))
    {
       str+=' AND Priority=\''+ priority+'\'';
    }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status =\''+ status+'\'';
    }
    
    if(String.isNotBlank(CStatus))
    {
       str+=' AND CStatus__c=\''+ CStatus+'\'';
    }
    
    //if(String.isNotBlank(subject))
    //{
    //   str+=' AND Subject Like \''+ subject+'\'';
   // }
    
    //if(String.isNotBlank(description))
    //{
     //  str+=' AND Description Like \''+ description+'\'';
    //}
    if(String.isNotBlank(Keyword))
   {
      str+=' AND (Subject Like\'%'+ Keyword+'%\'';
      str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
   }  
   System.debug(str);
    caseList=Database.query(str);
    return caseList;
    
    
}
}



 
Hi there,

I got in between a test class which is should cover both POST and Get Method, for my test the code coverage is just 35%

Can someone help to get 100% code coverage?

Below my apex class,

@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID ){
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String doc=EncodingUtil.Base64Encode(req.requestBody);
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = 'Id';
                
        insert a;
        
    }
}

Test Class,
@isTest
private class CaseAttachmentTest {
    @isTest static void testCaseAttachmentOne() {
    
  Test.startTest();
  
  

    //create account
    Account acc = new Account();
    //enter details  
    acc.Name = 'Test Account';
    insert acc;
    
    //create case
    Case c = new Case();
    //enter details
    c.AccountId = acc.Id;
    c.Type = 'My Type';
    c.Origin = 'My Origin';
    c.Status = 'My Status';
    insert c;
  

   RestRequest req = new RestRequest(); 
   RestResponse res = new RestResponse();

    req.requestURI = '/services/apexrest/CaseAccountid/'+c.accountId;  //Request URL
    // req.requestBody = Blob.valueof(Body);
    RestContext.request = req;
    RestContext.response= res;
    CaseAttachment.getCaseById();
    Test.stopTest();



     
        
   
  
  
  
    }
    
}


TIA



 
Hi there,
I am struggling to write a test class for below, can some help on this asap?

@RestResource(urlMapping='/CaseAccountid/*')
global with sharing class CaseAccountid{

@HttpGet
    global static List<Case> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<case> result =  [Select id, IsEscalated, Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c from Case where AccountId = :Id];
        return result;
    }
}
Here I am trying to get value dynamically from few different fields include, Account, Status, Tracker, Priority, ContactEmail and list down the list of case that matchs the criteria.

When I execute the below code I am getting  system.QueryException: invalid ID field: null

@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpPost
    global static List<Case> dopostCase(String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String accid) {
    List<Case> caseList = new List<Case>();
    String str='Select id, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed from Case where accountid =\''+ null +'\'';
    
    if(String.isBlank(accid))
    {
       str+=' AND AccountId=\''+ accid+'\'';
    }
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
     if(String.isNotBlank(priority))
    {
       str+=' AND Priority=\''+ priority+'\'';
    }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status =\''+ status+'\'';
    }
    
    if(String.isNotBlank(CStatus))
    {
       str+=' AND CStatus__c=\''+ CStatus+'\'';
    }
    if(String.isNotBlank(Keyword))
   {
      str+=' AND (Subject Like\''+ Keyword+'\'';
      str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
   }  
   System.debug(str);
    caseList=Database.query(str);
    return caseList;
    
    
}
}

Hi All,

I have a requirement where I have to send emailmessage to web service via rest API (/services/data/v39.0/sobjects/EmailMessage/{Id}) same like that I have to send the attachment attached to that email via rest API.

I tried standard Attachment and ContentDocument API which is not working.
I would be so thankful If someone helps me with this

 

Hi,

I am trying to excute the below Apex class and stuck with an error. 
Can someone hlep me with this?
global class CaseWeberviceControllers {
     Webservice static List<Case> getCase(String accounid,String tracker,String priority,String contactEmail,String status)
  {
  
    list<Case> caseList = new List<Case>();
    
    String str='Select id from Case where accountid =\''+ accounid+'\'';
    
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
     if(String.isNotBlank(priority))
    {
       str+=' AND Priority=\''+ priority+'\'';
    }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status=\''+ status+'\'';
    }
    
    caseList = Database.query(str);
    return caseList;
    
  }

}

In Worbench,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:str="http://soap.sforce.com/schemas/class/CaseWeberviceControllers">
  <soapenv:Header>
    <str:SessionHeader>
<str:sessionid>!AQkAQC3.022RUHDz4L8w1j4yuO5wh6B2QEcKEyISScpVdDuJvWRVgbdGI4N6vbjSAZpX.X0vmq7zFOHA1L6dHZIUVzSpSMCA</str:sessionid>
</str:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
<str:getCase>
<str:Tracker__c>Incident</str:Tracker__c>
<str:Priority>1</str:Priority>
</str:getCase>
   </soapenv:Body>
</soapenv:Envelope>


Raw Response
HTTP/1.1 500 Server Error Date: Fri, 23 Nov 2018 09:49:25 GMT Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private Set-Cookie: BrowserId=1LS3fvbPQeaj8Tefpb9ITw;Path=/;Domain=.salesforce.com;Expires=Tue, 22-Jan-2019 09:49:25 GMT;Max-Age=5184000 Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: text/xml; charset=utf-8 Transfer-Encoding: chunked
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Element {http://soap.sforce.com/schemas/class/CaseWeberviceControllers}sessionid invalid at this location</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>
 
Hi There,

I my trying to narrow down my query by have more than one filter, with a sing REST API that allows me to enter Status, Case Number and Keyword within a account.
Below the code,

@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpGet
    global static List<Case> getCaseByyId() {
    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;
    String search_query= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    List<Case> results = [Select id, Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, 
                                        Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
                                        ContactId, OwnerId, CaseNumber from Case where Status=:search_query];
                                                                             return results;
}

@HttpGet
    global static List<List<Case>> getCase() {
    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;
    String search_query= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    List<List<Case>> results = [FIND: search_query IN ALL FIELDS RETURNING Case ( id, Call_Back_Type__c, IsEscalated, 
                                                                             Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, 
                                                                             Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
                                                                             ContactId, OwnerId, CaseNumber ORDER BY status, priority, type, Version__c, Tracker__c, OwneEmail__c, subject )];
                                                                             return results;
}
}

Can someone help me through this?
 
Hi,

I am trying to query across all field with an object(case), just like the search bar so that whatever keyword I enter it should query all field and throw back list of record that matach the keyword,
below the code I use,
@RestResource(urlMapping='/Casequery/*')
global with sharing class CaseQuery {
    
    @HttpGet
    global static List<Case> getCase() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        List<List<Case>> results = [FIND 'map*' IN ALL FIELDS RETURNING Case (id, Call_Back_Type__c, IsEscalated, 
                                                                             Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, 
                                                                             Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
                                                                             ContactId, OwnerId, CaseNumber)];
                                                                             return results;
}
}

and geting an error:Illegal conversion from List<List<Case>> to List<Case>

Any thought on this??



 
Hello,

I got stuck in a project were I have to integrated Service cloud with out Support Web Page.
we user Rest API and all the data will get stored in Salesfroce not in our Support page, now they want a search and filter option and I have send data via API, Just like the Serach box in Salesforce.
The below API works fine, but its static it there a way to make it dynamic so that I can type what ever keyword and related records should get displayed in the webpage.

"/services/data/v41.0/queryAll?q=Select+Id+From+Case+where+Contact.Email" 
Hi There,

Is there a way to add line space between fields while send via rest api??
below the apex class I use to send data to my front end

@RestResource(urlMapping='/EmailMessages/*')
global with sharing class EmailMessages{

@HttpGet
    global static List<EmailMessage> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<EmailMessage> result =  [Select Id, Status, Headers, Subject, FromName, HtmlBody, Incoming, ParentId, TextBody, CcAddress, IsDeleted, ToAddress, ActivityId, BccAddress, CreatedById, CreatedDate, FromAddress, MessageDate, RelatedToId, HasAttachment, SystemModstamp, ThreadIdentifier, MessageIdentifier, IsExternallyVisible, ValidatedFromAddress, ReplyToEmailMessageId From EmailMessage where ParentId = :ID];
        return result;
    }
}

Expect Out:
donotreply@mcafee.comWed, Oct 10, 10:17 PM
to me
Dear McAfee Subscriber,

Thank you for activating your McAfee® security software.  You are now entitled to updates and upgrades for your McAfee products.
We’ve created your McAfee account with the email address you provided when you first set up your PC. 

But Actual Out is;
donotreply@mcafee.com Wed, Oct 10, 10:17 PM to me Dear McAfee Subscriber, Thank you for activating your McAfee® security software. You are now entitled to updates and upgrades for your McAfee products. We’ve created your McAfee account with the email address you provided when you first set up your PC. Next steps

Can someone help me on this.

TIA
 
Hi All,

I have two visual force page as seen below,

<apex:page tabStyle="Case" action="/500?fcf=00B7F00000287BO" ></apex:page>
<apex:page showHeader="true" tabstyle="Case" action="/500?fcf=00B0l0000010NyT"></apex:page>

Is there a way to club these two VF page into one. I tried Apex: Include but doesn't work.

I heard about iframe, but I don't have any idea on this.

Can someone help me to achieve this one?

Thanks in advance.

 
Hi All,

We are in process of Integrating one of our web pages with Service cloud. so that our customer will create a ticket that will pass on to salesforce and get saved in Case Object. I have written some custom API for this.

Same like passing the data, we have to send an Attachment from our web pages to salesforce which works fine, but when I click "View file" it showing "File format not found"

Can someone help me with this??

Thanks in advance.

 
I got stuck here, can someone help to slove this error,
below my code,
Trigger:
trigger Level2Update on Account_Case_Escalation__c (after update) {

for(Account_Case_Escalation__c ACE: trigger.new)
{
util.callwebservice(ace.Account__c, ace.Level_2_Name__c, ace.Level_2_Email__c, ace.L2_Title__c);
system.debug('Account Case account  '+ ace.Account__c);
system.debug('Account Case email  '+ ace.Level_2_Email__c);
system.debug('Account Case name  '+ ace.Level_2_Name__c);
system.debug('Account Case Title  '+ ace.L2_Title__c);


}

}

Apex Class:

public with sharing class util
{
@future(callout=true)
public static  void callwebservice(Id Accid, String name, String email, String title)

{
HTTP auth = new HTTP()    ;
//List<contact> acc = [Select Id, Name from Account Where Id IN :recordIds];
//String Body = "Accountid":cid + "id":aid;

HTTPRequest r = new HTTPRequest();
r.setHeader('Content-Type','application/json');
String username = 'appviewxsupport2@yopmail.com';
String password = 'Appviewx@123';

Blob headerValue = Blob.valueOf(username+ ':' + password );
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
r.setHeader('Authorization', authorizationHeader);
r.setEndpoint('https://salesforceintegrationstaging.payoda.com/api/web/v1/accounts/updateaccountdetails');
r.setMethod('POST');
r.setBody('{"account_id":"accid","level_2_name":"name","level_2_email":"email","level_2_title":"title"}');
//r.setBody(body);   
HTTPResponse authresp=new HttpResponse();
authresp = auth.send(r);
system.debug('Statuscode Expected'+ authresp.getStatusCode());
System.debug('Body expected' + authresp.getBody());
}
}

When I run the above code below the error i facing,
Error: System.HttpResponse[Status=Unauthorized, StatusCode=401

TIA
 
HI there,

Below my code was working fine, but suddenly pass an error, when I try to attach a document,

Custom API for Case Attachment,
@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID){

        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        if(Test.isRunningTest()){
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        //String doc=EncodingUtil.Base64Encode(req.requestBody);
        }
        
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = ParentID;
                
        insert a;
        
        
    }
}

Below the resultUser-added imageCan someone help with this asap.
Hi there,

I have field name "Priority" with values 1,2,3,4.

if(String.isNotBlank(priority))
    {    
       str+=' AND Priority = \''+ priority+'\'';
    }
As of now I can able to pass only one value at a time is there a way to pass like this "Priority":"1,2"
Hi there,
I got stuck here, out of 13 filter criteria I have achive 11 and rest I am stuggling to sorting out,

Below my code, here I am trying to achive is, 
In the Priority field, which is single pick list field where I have pass more than one value
For Example: Priority: 1 & 2
Secondly in the CreatedDate field I have to pass a date range
For Example: Createddate= 2018-12-12 to 201-1-1

Apex Class,
@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpPost
    global static List<Case> dopostCase(String CreateDate,String Owneremail, String Bugis, String Version, String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String Product, String Name, String OwnerName) {
    List<Case> caseList = new List<Case>();
    String str='Select id, CreatedDate, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed, Product_Type__c, ContactName__c, GS_Account__c from Case where accountid =\''+ accountid +'\'';
    
    if(String.isNotBlank(Owneremail))
    {
       str+=' AND OwneEmail__c=\''+ Owneremail+'\'';
    }
    if(String.isNotBlank(Bugis))
    {
       str+=' AND BugIs__c=\''+ Bugis+'\'';
    }
    if(String.isNotBlank(Version))
    {
       str+=' AND Version__c=\''+ Version+'\'';
    }
    
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
    // if(String.isNotBlank(priority))
   // {
   //    str+=' AND Priority=\''+ priority+'\'';
   // }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status =\''+ status+'\'';
    }
    
    if(String.isNotBlank(CStatus))
    {
       str+=' AND CStatus__c=\''+ CStatus+'\'';
    }
    if(String.isNotBlank(Product))
    {
       str+=' AND Product_Type__c=\''+ Product+'\'';
    }
    if(String.isNotBlank(Name))
    {
       str+=' AND ContactName__c Like \'%'+ Name+'%\'';
    }
    if(String.isNotBlank(OwnerName))
    {
       str+=' AND Case_Owner_Name__c Like \'%'+ OwnerName+'%\'';
    }
    
    if(String.isNotBlank(priority))
    {
    for(string pstring : priority.split(',')){
       str+=' AND Priority=\''+ pstring +'\'';
     }

}
 if(String.isNotBlank(CreateDate))
    {
       str+=' AND CreatedDate = \''+ CreateDate+'\'';
    }
    if(String.isNotBlank(Keyword))
   {
      str+=' AND (Subject Like\'%'+ Keyword+'%\'';
      str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
   }  
   System.debug(str);
    caseList=Database.query(str);
    return caseList;
}
}
 
Can someone help with this,
TIA
Hi there,

Can someone help with test class for below two Apex class??

@RestResource(urlMapping='/CaseAttachment/*')
global with sharing class CaseAttachment{

@HttpGet
    global static List<Attachment> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Attachment> result =  [Select id, Name, OwnerId, BodyLength, LastModifiedById, LastModifiedDate, ContentType, Body, Description, CreatedDate, CreatedById from Attachment where ParentId = :Id];
        return result;
        }
           
@HttpPost
  global static void doget(String type, String body, String ContentType, String ParentID ){
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String CaseName=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        String doc=EncodingUtil.Base64Encode(req.requestBody);
         Attachment a = new Attachment();
            a.Name = type;
            a.Body = Blob.valueOf(body);           
            a.ContentType = ContentType;
            a.ParentId = 'Id';
                
        insert a;
        
    }
}

and-------------------------------------------------------------------------------------------------------

@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
    
    @HttpPost
    global static List<Case> dopostCase(String Owneremail, String Bugis, String Version, String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword) {
    List<Case> caseList = new List<Case>();
    String str='Select id, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed from Case where accountid =\''+ accountid +'\'';
    
    if(String.isNotBlank(Owneremail))
    {
       str+=' AND OwneEmail__c=\''+ Owneremail+'\'';
    }
    if(String.isNotBlank(Bugis))
    {
       str+=' AND BugIs__c=\''+ Bugis+'\'';
    }
    if(String.isNotBlank(Version))
    {
       str+=' AND Version__c=\''+ Version+'\'';
    }
    
    if(String.isNotBlank(tracker))
    {
       str+=' AND Tracker__c =\''+ tracker+'\'';
    }
     if(String.isNotBlank(priority))
    {
       str+=' AND Priority=\''+ priority+'\'';
    }
     if(String.isNotBlank(contactEmail))
    {
       str+=' AND ContactEmail=\''+ contactEmail+'\'';
    }
     if(String.isNotBlank(status))
    {
       str+=' AND Status =\''+ status+'\'';
    }
    
    if(String.isNotBlank(CStatus))
    {
       str+=' AND CStatus__c=\''+ CStatus+'\'';
    }
    
    //if(String.isNotBlank(subject))
    //{
    //   str+=' AND Subject Like \''+ subject+'\'';
   // }
    
    //if(String.isNotBlank(description))
    //{
     //  str+=' AND Description Like \''+ description+'\'';
    //}
    if(String.isNotBlank(Keyword))
   {
      str+=' AND (Subject Like\'%'+ Keyword+'%\'';
      str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
   }  
   System.debug(str);
    caseList=Database.query(str);
    return caseList;
    
    
}
}



 
Hi there,
I am struggling to write a test class for below, can some help on this asap?

@RestResource(urlMapping='/CaseAccountid/*')
global with sharing class CaseAccountid{

@HttpGet
    global static List<Case> getCaseById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<case> result =  [Select id, IsEscalated, Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c from Case where AccountId = :Id];
        return result;
    }
}
Hi,

I am trying to query across all field with an object(case), just like the search bar so that whatever keyword I enter it should query all field and throw back list of record that matach the keyword,
below the code I use,
@RestResource(urlMapping='/Casequery/*')
global with sharing class CaseQuery {
    
    @HttpGet
    global static List<Case> getCase() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        List<List<Case>> results = [FIND 'map*' IN ALL FIELDS RETURNING Case (id, Call_Back_Type__c, IsEscalated, 
                                                                             Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c, 
                                                                             Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
                                                                             ContactId, OwnerId, CaseNumber)];
                                                                             return results;
}
}

and geting an error:Illegal conversion from List<List<Case>> to List<Case>

Any thought on this??



 
Hello,

I got stuck in a project were I have to integrated Service cloud with out Support Web Page.
we user Rest API and all the data will get stored in Salesfroce not in our Support page, now they want a search and filter option and I have send data via API, Just like the Serach box in Salesforce.
The below API works fine, but its static it there a way to make it dynamic so that I can type what ever keyword and related records should get displayed in the webpage.

"/services/data/v41.0/queryAll?q=Select+Id+From+Case+where+Contact.Email" 
Hi All,

I have two visual force page as seen below,

<apex:page tabStyle="Case" action="/500?fcf=00B7F00000287BO" ></apex:page>
<apex:page showHeader="true" tabstyle="Case" action="/500?fcf=00B0l0000010NyT"></apex:page>

Is there a way to club these two VF page into one. I tried Apex: Include but doesn't work.

I heard about iframe, but I don't have any idea on this.

Can someone help me to achieve this one?

Thanks in advance.

 
Hi there,

I have two customer VF page as seen below,

1. (My Case) <apex:page tabStyle="Case" action="/500?fcf=00B7F00000287BO" > </apex:page>
2. (Unassigned case)<apex:page showHeader="true" tabstyle="Case" action="/500?fcf=00B0l0000010NyT"> </apex:page>

Now to  I have to collide these two VF pages into one. So that the user able to see both"My case" and "Unassigned" case in a single window.

Can someone help me to achieve the above?

Thanks in advance.



 
Hi All,

I have a requirement where I have to display "Contact Name" or "User Name" based on the Id given a particular field.

For example: Here my Input field is "CreatedBy__c" and my output field is "Contact_Name__c",
Contact Id is 0030l00000IcLXE (Draco) and user Id is 0050l000000Muxz(Ajay).
If CreatedBy__c = 0030l00000IcLXE then the Contact_Name__c = Draco like wise if CreatedBy__c = 0050l000000Muxzthen the Contact_Name__c = Ajay.

Can someone help me on this
  
Hi All,

I created a custom object Name "Casecomments" related to Case object and below the Apex code I use to view all "Casecomments" created to a particular case by passing case id,

@RestResource(urlMapping='/CaseComments__c/*')
global with sharing class CaseComments__cListview{

@HttpGet
    global static List<CaseComments__c> getCaseComments__cId() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<CaseComments__c> result =  [Select id from CaseComments__c where Case__c=:id];
        return result;
    }

I am facing this error,
Error: Compile Error: Invalid character in identifier: CaseComments__cListview at line 2 column 27

can someone help me on this. 
thanks in advance.
 
Hi All ,

Hi,
I am trying to list all case created to particular account here the parameter is the CaseId, below the apex code,
below the code,

RestResource(urlMapping='/NotesListView/*')
global with sharing class NotesListView{

@HttpGet
    global static List<Note> getNoteById() {
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String Id= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
          List<Note> result = [Select Id, Title, Body from Note where ParentId= :Id];
        return result;
    }
}

Where I Pass CaseId in ParentId.