Lookup Field returns null from rbf_selectQuery but not from

Posted by awbranch on 04-Jun-2014 13:39

I have 2 related objects. Employee and Company. Cardinality is "Many Employees to One Company".
The Company lookup field in the Employee object has the integration code "company"
The relationship name is "R1234".

Suppose I have the following employees with their respective company ids.

Employee: "John Doe" -  ID: 100 - Company ID: 200

Employee: "Sue Smith" - ID: 101 - Company ID: 201 

If I run an the following 2 queries for John Doe as follows:

rbf_selectQuery("SELECT company FROM employee WHERE id = 200", 1, displayCompanyId);

rbf_getRelatedIds("R1234", 100, displayRelatedCompanyId);

Both displayCompanyId and displayRelatedCompanyId display  200 as expected.

However if run the two queries for Sue Smith then displayCompanyId shows "null" while displayRelatedCompanyId displays 201.

So essentially the rbf_selectQuery and rbf_getRelatedIds are out of sync with each other.

If I view Sue Smith or the company with ID 201 in the admin interface everything looks fine. You can see her related company as expected. In my case, this problem happens for any employee assigned to company 201. 

Is this expected behavior. Why would it be inconsistent between different employees?


Build Date 02/18/2014

All Replies

Posted by Laurent on 04-Jun-2014 13:49

I assume that the rbf_selectQuery() is looking for employees whose ID = 100 and not 200

Posted by awbranch on 05-Jun-2014 10:38

Yes typo, that should be:

rbf_selectQuery("SELECT company FROM employee WHERE id = 100", 1, displayCompanyId);

Posted by awbranch on 06-Jun-2014 14:58

Yes typo, that should be:

rbf_selectQuery("SELECT company FROM employee WHERE id = 100", 1, displayCompanyId);

Posted by Laurent on 06-Jun-2014 15:19

You might want to create a ticket with Support if your company has already done so, as this type of issue is unlikely to get fixed with just a few instructions.

Posted by refael shira on 26-Feb-2018 03:06

Hello everyone,

I have the same problem.

Has it been fixed?

Has a solution been found?

Best Regards,


Posted by Mohammed Siraj on 27-Feb-2018 01:16

For fetching lookup field values for a record, it is advised to use Server-side API getRelatedIds instead of selectQuery.

selectQuery implementation is optimized to fetch field values persisted orthogonal & specific to each individual record. However for lookup field values which are basically references to other records in the system, selectQuery results may be inconsistent.

That said, for selectQuery API we have done additional corrections in Rollbase 5.1 release to ensure it retrieves the correct set of values  for single cardinality lookup fields. That is when fetching single value lookup fields ( 1 side of relationship in 1:1, 1:M , M:1), selectQuery API will also return results consistent with getRelatedIds.

This thread is closed