+ Start a Discussion
Esha Sharma 4Esha Sharma 4 

Null while fetching a field + partner connection

Below is what I am doing

 String queryStr1 = "SELECT CaseNumber,ID, SM_Change_Area__c FROM Case" + " WHERE  SM_Change__c in ('Standard', 'Minor')  AND SM_Change_Area__c in ('Database - Select Script', 'Database - Database Edit Script')" + " AND Status in ('Peer Approval', 'Pending Eng Peer Approval')" ;
            qr = partner_connection.query(queryStr1);

            if (qr.getSize() > 0) {
            for (SObject c:qr.getRecords()) {               
                    caseNumber = c.getField("CaseNumber").toString();      
                    System.out.println(caseNumber); //gives me the caseNumber
                    QueryResult qr2 = partner_connection.query("SELECT SM_Data_center__c,ID from SM_Change_implementation__c where case__c='" + c.getId() + "'");
                    System.out.println(qr2.getRecords()[0].getSObjectField("SM_Data_center__c")); //gives me null 

I can see qr2.getRecords().toString() prints the entire XML object and it has this field and value. 
Hi Esha,

Please try 
for (int i = 0; i < qr2.length; i++){
SM_Change_implementation__c  sm = (SM_Change_implementation__c ) qr2[i];

Hope it solves the issue.