Select Query REST API - Get Related Object 'Name' -

Posted by IramK on 22-Dec-2014 08:45

Hello,

Is there a way I could get the related Object 'name' for an existing record using select query? Currently it returns back the ID of the related record. Kindly let me know.

Posted by pvorobie on 22-Dec-2014 15:27

Correct, this will work. URL example tested in my environment:

http://localhost:8080/rest/api/selectQuery?query=select+name+from+child+where+R629945%3D629958&maxRows=500&sessionId=f8707ccd173d4db78a552ece7894996c@5903

Query:

select name from child where R629945=629958

This is assuming there is 1:N relationship between "parent" and "child" objects and 629958 is record's ID on parent side.

All Replies

Posted by matman on 22-Dec-2014 08:51

You could set the "composite" parameter of your REST API call to "1", this is "0" by default. When set to "1" it will include the related record in the output. This included related record will contain the "name" field.

Posted by IramK on 22-Dec-2014 08:58

I dont think you have the parameter "composite" in a SelectQuery REST API call?

Posted by matman on 22-Dec-2014 09:08

Ah sorry, no you don't have that with queries. You could use the template way of fetching data, example: "SELECT "{!R116103884.name}" FROM subscription". Do not forget the quotes around the {!R116103884.name} or it won't work.

Posted by IramK on 22-Dec-2014 09:19

That is the response i get back..:

<resp status="ok">

  <row>

     <col>{!Raccount.name}</col>

  </row>

  <row>

     <col>{!Raccount.name}</col>

  </row>

  <row>

     <col>{!Raccount.name}</col>

  </row>

</resp>

Doesnt look right to me.

Posted by matman on 22-Dec-2014 09:47

When running it in Rollbase itself, those template tokens actually do get replaced. Unfortunately this doesn't seem to work for the REST API.

I can't find a way to solve this problem using only one query. Rollbase queries don't seem to accept more than 1 object in the FROM and also subqueries the way I tried them aren't possible :/

Posted by Orchid Corpin on 22-Dec-2014 10:04

Hi,

In REST API we cannot get the value "name" of the related object, at this point you may want to

1. Add another query to get the name of the related record, as matman said only one possible query every request

2. Create another Text Field that will hold the name of that related object, update that field every create or update of the record via Update Field trigger. In your REST query just select that text field.

Regards,

Orchid

Posted by pvorobie on 22-Dec-2014 10:49

REST API selectQuery works the same way as server-side API selectQuery. Please prepare query using debugger "Test Query" tool.

Posted by IramK on 22-Dec-2014 11:20

Could you suggest a possible answer to this with an appropriate query?

Posted by Orchid Corpin on 22-Dec-2014 13:06

Hi,

I tested the REST API query and could not get directly the name too of the related object. This could be a possible enhancement to future release.
Other alternative way above, I would suggest #2, it is easier to setup :)

Regards,
Orchid

Posted by pvorobie on 22-Dec-2014 14:43

Please provide query you're using.

Posted by murali on 22-Dec-2014 15:20

Assume  that you have the following relationship.
 
1 Professor  : n Student  //  we’ll assume integration names are  my_prof  and my_student
 
 
Let the relationship id be  R12344
 
To get All students related to  Professor ( with id   100 ) ; you should query on the Student  Object
 
 
SELECT id, name from my_student where  R12344= 100   // id  being the ID of the Professor Object. 
 
 
 
[collapse]
From: IramK [mailto:bounce-IramK@community.progress.com]
Sent: Monday, December 22, 2014 12:21 PM
To: TU.Rollbase@community.progress.com
Subject: RE: [Technical Users - Rollbase] Select Query REST API - Get Related Object 'Name' - Not ID
 
Reply by IramK

Could you suggest a possible answer to this with an appropriate query?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by pvorobie on 22-Dec-2014 15:27

Correct, this will work. URL example tested in my environment:

http://localhost:8080/rest/api/selectQuery?query=select+name+from+child+where+R629945%3D629958&maxRows=500&sessionId=f8707ccd173d4db78a552ece7894996c@5903

Query:

select name from child where R629945=629958

This is assuming there is 1:N relationship between "parent" and "child" objects and 629958 is record's ID on parent side.

This thread is closed