3

To put you on perspective, I've created a Detail Page Button that displays in a new window some result data from a callout to a SOAP web service.

The thing is, I've tried it in a sanbox, and it works perfectly. It displays the data in JSON format (for testing) and then in a display block after deserialize the JSON:

enter image description here

However, surprisingly for me, I've repeated the process in another Sandbox (adjusting of course the code to the new objects attributes name in the new sandbox) and the result is as follow: enter image description here

This is the code for the Apex page:

<apex:page controller="AlumnosFromOP_Controller">

<apex:pageBlock title="Listado de alumnos matriculados">
    <apex:outputText style="font-style:italic" value="Información de todos los alumnos matriculados en el Grupo:  {0} ({1}).">
        <apex:param value="{!groupName}"/>
        <apex:param value="{!groupID}"/>
    </apex:outputText>
</apex:pageBlock>

<apex:pageBlock title="Test">
    <apex:outputText style="font-style:italic" value="{0}">
        <apex:param value="{!testVar}"/>
    </apex:outputText>
</apex:pageBlock>

<apex:pageBlock title="Students">
    <apex:pageBlockTable value="{!alumnosList}" var="alumno">
        <apex:column value="{!alumno.nombre__c}"/>
        <apex:column value="{!alumno.Primer_Apellido__c}"/>
        <apex:column value="{!alumno.email__c}"/>
        <apex:column value="{!alumno.DNI__c}"/>
    </apex:pageBlockTable>
</apex:pageBlock>      

And the code in the Controller where the callout is made:

    public class AlumnosFromOP_Controller
    {    
    public String groupID{get;set;}
    public String groupName{get;set;}
    public String testVar{get;set;}
    public List<Alumno__c> alumnosList{get;set;}

    //Constructor 
    public AlumnosFromOP_Controller(){

        groupID = ApexPages.currentPage().getParameters().get('gID');
        groupName = ApexPages.currentPage().getParameters().get('gNombre');

        alumnosList = new List<Alumno__c>();

        String myJSON = getAlumnosFromOP(groupID);

        testVar = myJSON;

        alumnosList = (List<Alumno__c>)JSON.deserialize(myJSON, List<Alumno__c>.class);
    }


    private String getAlumnosFromOP(String groupID)
    {
        try{
                //Open connection with SOAP web service
                OP_SF_Interaction.OP_SF_InteractionPort stub = new  OP_SF_Interaction.OP_SF_InteractionPort();

......

So, as in both cases, the JSON is well returned from the callout to the SOAP web service, I'm assumning ¿the bug is in the process of deserializing the JSON?; is the List alumnosLIst the one is displaying in the first case but not displaying in the second one

But it's odd, because the JSON deserializing doesn't creates any exception or error.

I'm running out of ideas...

UPDATE A comparison of the debugging in both sandbox, just in case it helps. enter image description here

6
  • Just to be sure: which API version did you save the class against? Only after 24.0 the JSON.deserialize returns an error for missing fields on an object. – Guy Clairbois Apr 28 '15 at 11:27
  • @guy I'm using the 33.0 API version – daniegarcia254 Apr 28 '15 at 12:29
  • 1
    It must be a mismatch between the 2 object models (e.g. API object/field names). You say you adjusted the code to the new attribute names. But the fieldnames in the JSON strings still look the same. What if you put a system.debug(alumnosList); after the deserialize? – Guy Clairbois Apr 28 '15 at 12:38
  • @guy I've put the System.debug(alumnosList) and it returns "15:45:35:524 USER_DEBUG [19]|DEBUG|(Alumno__c:{}, Alumno__c:{}, Alumno__c:{}, Alumno__c:{}, Alumno__c:{}, Alumno__c:{}, Alumno__c:{})", it doesn't transform the JSON into objects =( but I've compared the two objects in each sandbox and all fileds have the same attribute names, so the problem isn't about that. I've included an image of the debugging in the question in case it helps. – daniegarcia254 Apr 28 '15 at 14:01
  • 1
    Does you system admin profile have viewing rights to those fields? If deployed via deployment sets that is not done by default.. – Guy Clairbois Apr 28 '15 at 14:04
1

Does you system admin profile have viewing rights to those fields? If deployed via deployment sets that is not done by default..

1
  • Oh man, genius! I was assuming that all permissions were granted to me as Admin. Thanks so much! – daniegarcia254 Apr 28 '15 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.