+ Start a Discussion
andyCandyC 

SOQL-R Parents and Partner WSDL

The following query gets a parent object's name

"Select  s.TUser__c, TUser__r.Name From TUser_Security__c s"

In Java, using the Partner WSDL,

get_any()[0].getValue() gives me the first column value

get_any()[1].getValue() returns null, so I'm obviously doing something wrong.

I can see that get_any()[1].getName() gives me the relationship name.

Please could someone point me in the direction of the way I get the value - the examples in the docs don't have parents.

Cheers
Andy

digeratadigerata
I'm new to the API, but had troubles using just Name.  I ended up using FirstName and LastName.  Does that work?
andyCandyC
Right - I found a way... seems I can get it by iterating through the child elements until I find the one I need - in this case "Name".

      Iterator it2 = user.get_any()[1].getChildElements();
      while (it2.hasNext()) {
        MessageElement me = (MessageElement)it2.next();
        System.out.println(me.getName() + "..." + me.getValue());
        if (me.getName().equals("Name")) {
          name = me.getValue(); 
        }
      }

I have found this by trial and error - if there is a better way, please can someone post it here.

Cheers
Andy

SuperfellSuperfell
Have you tried get_any()[1].getObjectValue() ?
andyCandyC
Thanks for the pointer...this seems to do the trick:

((SObject)user.get_any()[1].getObjectValue()).get_any()[0].getValue()