public String getRecordValue( SObject con, String fieldname ) throws KettleException {
    String[] fieldHierarchy = fieldname.split( "\\." );
    if ( con == null ) {
      return null;
    } else {
      XmlObject element = getMessageElementForHierarchy( con, fieldHierarchy );
      if ( element != null ) {
        Object object = element.getValue();
        if ( object != null ) {
          if ( object instanceof QueryResult ) {
            return buildJsonQueryResult( (QueryResult) object );
          }
          return String.valueOf( object );
        } else {
          return (String) element.getValue();
        }
      }
    }
    return null;
  }
@Test //PDI-15973
  public void testGetRecordValue() throws Exception {  //PDI-15973
    SalesforceConnection conn = mock( SalesforceConnection.class, Mockito.CALLS_REAL_METHODS );
    SObject sObject = new SObject();
    sObject.setName( new QName( Constants.PARTNER_SOBJECT_NS, "sObject" ) );

    SObject testObject = createObject( "field", "value" );
    sObject.addField( "field", testObject );
    assertEquals( "Get value of simple record", "value", conn.getRecordValue( sObject, "field" ) );

    SObject parentObject = createObject( "parentField", null );
    sObject.addField( "parentField", parentObject );
    SObject childObject = createObject( "subField", "subValue" );
    parentObject.addField( "subField", childObject );
    assertEquals( "Get value of record with hierarchy", "subValue", conn.getRecordValue( sObject, "parentField.subField" ) );

    SObject parentObject2 = createObject( "parentField2", null );
    sObject.addField( "parentField2", parentObject2 );
    SObject childObject2 = createObject( "subField2", null );
    parentObject2.addField( "subField2", childObject2 );
    assertNull( "Get value of record with hierarchy", conn.getRecordValue( sObject, "parentField2.subField2" ) );

    SObject parentObject3 = createObject( "parentField3", null );
    sObject.addField( "parentField3", parentObject3 );
    parentObject3.addField( "subField3", null );
    assertNull( "Get value of record with hierarchy", conn.getRecordValue( sObject, "parentField3.subField3" ) );

    XmlObject nullObject = new XmlObject( new QName( "nullField" ) );
    sObject.addField( "nullField", nullObject );
    assertEquals( "Get null value when relational query id is null", null, conn.getRecordValue( sObject, "nullField.childField" ) );
  }