I would like to know how we can query object and related object in a single query. I'm new to Rollbase.
ex: rbf_selectQuery("SELECT id,name, R11XX FROM bXXX b, 100, callback1); // where R11XX is the relationship name of other object.
I'm looking to construct a query which will also show values from other related objects.
Can anyone help. Thanks in advance.
Use rbf_selectValue() using your Query.
Hi Iramk. Thanks for the reply.
But my query may return multiple records and I need to process all records so I couldn't use this rbf_selectValue() method.
Hi,
To get the related object's fields you can use rbf_getFields. If the record has multiple child you can use Loop_begin / loop_end if it is only one child then you use directly the rbf_getFields with the id of your related record.
<script> /* Assumes you are in the parent objects view page R56036 - > this is the related field product1 - > will be the object name of R56036 */ '{!#LOOP_BEGIN.R56036}' rbf_getFields("product1", parseInt("{!id}"), "name, product_code, unit_price", function(relName, objId, values) { console.log(values['name']); console.log(values['product_code']); console.log(values['unit_price']); }); '{!#LOOP_END.R56036}' </script>
Hope this may help.
Regards,
Orchid
Thank Orchid.
What I'm looking for is to show many to many relationship over the portal page. So for this we may need to query all the parents ids and then we would fetch the related child records.
In your previous example we are processing child records from the object view page but I was looking for such useful stuffs over the portal pages.
Can you assist?
Thanks,
Rohit
Yes sure! That code will work on portal page too (Record view). First, make sure you enable "Ajax calls" in Portal Properties.
You want the query to be in a Generic Page portal?
Regards,
Orchid
We may have problems querying all Parent records, assuming we are in the Generic Page we use selectQuery since we cannot use loop_begin/loop_end on this page type, maxRows in selectQuery is limited to 20,000
What is your main objective, so we can find another option?
Regards,
Orchid
Reply by Orchid CorpinWe may have problems querying all Parent records, assuming we are in the Generic Page we use selectQuery since we cannot use loop_begin/loop_end on this page type, maxRows in selectQuery is limited to 20,000
What is your main objective, so we can find another option?
Regards,
OrchidStop receiving emails on this subject.Flag this post as spam/abuse.
Simplest solution: create field of type "Related Field" on B object, point it to a field on A object. This way you don't need to query anything.
[mention:05b5f00eae4a468d844fa8bedcafd110:e9ed411860ed4f2ba0265705b8793d05] is right, this is much easier if you want to get the children from a parent's view page, no more query.
But since you are in a Generic Page you can't make use of that. I created a sample query from parent to child.
You may change: warehouse = parent, product1 = child
<script> //QUERY ALL PARENT rbf_selectQuery("SELECT name, id FROM warehouse", 5, my_callback); function my_callback(data) { for(i=0; i<data.length; i++) { console.log("Parent ID: "+data[i][1]); console.log("Parent Name: "+data[i][0]); /* QUERY ALL CHILD FROM EACH PARENT WHERE = QUERY CHILDREN WHICH HAS SAME ID AS THE CURRENT PARENT R56036 = parent ID */ rbf_selectQuery("SELECT name, id, R56036 FROM product1 WHERE R56036='"+data[i][1]+"'", 10, function(child) { for(x=0; x<child.length; x++) { console.log("Child ID of : "+child[x][2]+" : "+child[x][0]+" -- "+child[x][1]); } //END CHILDREN LOOP }); } //END ALL PARENT LOOP } </script>
Regards,
Orchid
Hi Rohit,
Are the suggested solution / workaround did fix the issue? or do you have any questions related to this thread?
Thank you.
Regards,
Orchid