• Jen Bran
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I am using the JSON2Apex Heroku app to automatically create my classes (thanks!), but I am having difficulting then using the information that is retrieved from that Class when the data is in an array.

I am doing a call out and then using the app "parse" function to parsing the http response body.  This does allow me to access the data for a particular string from the JSON, but as soon as I hit a LIST I cannot figure out how to access that List data without getting an illegal assignment from List to List.  Since this crosses multiple classes I will just post a snippet below to ask for help.  

        MUser md = New MUser();
        httpResponse http = HttpCallOut.callout('MemberByID',cnt.UniqueID__c,'test',null); //This is just b/c I have a class for calls outs
        UserByID obj = UserByID.parse(http.getBody());
        
        //Parse the info into an object to use in controller
        
        md.Email = obj.Data.Member.MemberEmail;
        md.Country = obj.Data.Member.Country.CountryName;
        md.MStatus = obj.Data.Member.MembershipStatus; //<--These are all individual fields in the JSON (Not array)
        md.StatusHistory = obj.Data.Member.StatusHistory; //Status History is an array of data containing status & createdDate

I understand the Heroku class and how it understands to parse the JSON, but there's very little actual documentation on accessing the information parsed later so I'm finding it difficult to address how the List items are accessed.  Let me know if you need to see the specific JSON2Heroku class, but even just answering in generalities would help!  Thank you thank you thank you!
Having some difficulties with consistent instructions on how to use apex to call a private external service and get a response using a shared/named principal authentication.  I do not want the user to know this occurs in the background as this will be used on a public facing visualforce page that will not have user authorization required.  Anyone able to point me to the correct instructions? I need help!

On a side note, also struggling with the "public user" as I cannot seem to find that to fix the settings in the system to make custom objects visible.
At this point I'm spinning my wheels and need to call on the experts.  I am pulling a list of Strings from SOQL and trying to put them in a String List, but not matter what method I use I always seem to end up with "Illegal assignment from List to List."  Once the list is populated, I want to use it and loop through each value and query a table for records that have the value.  Basically a series of events occur for each value in the string list.  All of the posts on line seem to be saying I have a class of the same name (nope) or I'm using a field when I need a list or something.  None of that seems accurate.  So why else would I be getting this error?  I've tried a lot of different methods to do the list and they all work up to a point, but then I try to use the values and I hit a wall and that error pops up.  Help!

In an nutshell (not actual code)

List<String> test = [Query from System]

for(Integer i=0; i< test.size(); i++){
   for (List<Case> cas : [Query from System where field = test[i]]{
        for(Case c: cas){
           str += c.CaseNumber + ',' + c.CustomField__c;
    }
   //do something with str
  }
}
Having some difficulties with consistent instructions on how to use apex to call a private external service and get a response using a shared/named principal authentication.  I do not want the user to know this occurs in the background as this will be used on a public facing visualforce page that will not have user authorization required.  Anyone able to point me to the correct instructions? I need help!

On a side note, also struggling with the "public user" as I cannot seem to find that to fix the settings in the system to make custom objects visible.
At this point I'm spinning my wheels and need to call on the experts.  I am pulling a list of Strings from SOQL and trying to put them in a String List, but not matter what method I use I always seem to end up with "Illegal assignment from List to List."  Once the list is populated, I want to use it and loop through each value and query a table for records that have the value.  Basically a series of events occur for each value in the string list.  All of the posts on line seem to be saying I have a class of the same name (nope) or I'm using a field when I need a list or something.  None of that seems accurate.  So why else would I be getting this error?  I've tried a lot of different methods to do the list and they all work up to a point, but then I try to use the values and I hit a wall and that error pops up.  Help!

In an nutshell (not actual code)

List<String> test = [Query from System]

for(Integer i=0; i< test.size(); i++){
   for (List<Case> cas : [Query from System where field = test[i]]{
        for(Case c: cas){
           str += c.CaseNumber + ',' + c.CustomField__c;
    }
   //do something with str
  }
}