• Patrick Jones 37
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I wrote the following code to get a 10 char string, reformat it and then pass to the Case query. 
 
@RestResource(urlMapping='/caseLookupAni/*')
global with sharing class caseLookupAni {

   @HttpGet
  global static List<Case> getOpenCases() {
    //  String passedANI = RestContext.request.params.get('ANI');
    string passedANI = '5207739050';  
    String PhoneDigits;
    String nondigits = '[^0-9]';
    PhoneDigits = passedANI.replaceAll(nondigits,'');
    String npa = (PhoneDigits.substring(0,3));
    String nxx = (PhoneDigits.substring(3,6));
    String nxxArea = (PhoneDigits.substring(6,10));  
    String formattedANI = '('+ npa + ') '+ nxx + '-' + nxxArea;  

    Case contactPhone=[SELECT Id, CaseNumber, Subject, Status, ContactPhone, OwnerId, Owner.Name FROM Case WHERE ContactPhone=: formattedANI LIMIT 1];
    
   System.debug(cases);
   List<Case> cases = contactPhone.Cases;
    return cases;
      } 
   
}

When I look at the logging, I see that the variables are being assigned correctly up until the final assignment. I can see the correctly returned result prior ... when it comes to the last assignment,  I see this: "VARIABLE_ASSIGNMENT|[18]|cases|[]|0x3ef6276e" which debug shows as "0". I dont understand why this is happening. 

Thank you in advance for any guidance.
Regards,
PJ
I am able to get an access_token passing SF via HTTP POST. Now that I have the access_token, how do I leverage in the URL to query for case numbers? I want to return "status" for a lookup on the case number that is passed to the API via the IVR. I think the base URL is incorrect for my query... 

I send the folloing to SFDC:
https://login.salesforce.com/services/oauth2/token/
grant_type=password
&client_id=xxxx
&client_secret=xxxx
&username=email@.com
&password=testpwd

and I receive the access_token successfully and I store that value in a variable
I then want to send a url query to SFDC and return all cases for a specific account ... the url that I use for that is where I am lost. What would an example be of the url for this? 

i tried http://instance.salesforce.com/sid=xxxx&case=xxxx
i get the login page for SFDC. I obviously dont understand why I cannot get beyond the access_token being granted ...

Thanks in advance for any guidance,
Patrick
 
I am able to get an access_token passing SF via HTTP POST. Now that I have the access_token, how do I leverage in the URL to query for case numbers? I want to return "status" for a lookup on the case number that is passed to the API via the IVR. I think the base URL is incorrect for my query... 

I send the folloing to SFDC:
https://login.salesforce.com/services/oauth2/token/
grant_type=password
&client_id=xxxx
&client_secret=xxxx
&username=email@.com
&password=testpwd

and I receive the access_token successfully and I store that value in a variable
I then want to send a url query to SFDC and return all cases for a specific account ... the url that I use for that is where I am lost. What would an example be of the url for this? 

i tried http://instance.salesforce.com/sid=xxxx&case=xxxx
i get the login page for SFDC. I obviously dont understand why I cannot get beyond the access_token being granted ...

Thanks in advance for any guidance,
Patrick