Relationship query problems

Posted by Rollbase User on 05-Mar-2012 18:33

Hi I have an issue trying to replicate the functionality of a View filter using an object script. I have 2 objects which are related. I open one object and can see that the lookup field for the relationship is set correctly. However, if I use rbv_api.selectQuery(...) to view the same data, it comes back with null. For example, I have the following object Foo: id: 12345678 name: Foo 1 with a related object Bar: id: 23456789 name: Bar 1 and a relationship integration code of R12345678. If I view the records in a page they are fine and relationship looks fine. In fact, using a View it is fine as well and the filtering on the view works as well (ie I can filter for all Foo that have empty Bar - ie no attached Bar). However, if I do something like var v = rbv_api.selectQuery("select name, R12345678 from Foo",200); rbv_api.printArr(v); I get a result of: { { Foo 1, null, }, } This is not the case for all Foo and Bar objects. Some do appear correctly in the selectQuery res

All Replies

Posted by Admin on 05-Mar-2012 21:38

Good example, I will add it to documentation. This query will only work (and actually works) if relationships is singular: 1-1 or N-1. For multiple relationships (1-N or N-N) use getRelatedIds API or template loops.

Posted by Admin on 05-Mar-2012 21:41

Chapter 6, page 27-28.

This thread is closed