How do we include related fields in a rbf_selectQuery select query. - Forum - Rollbase - Progress Community

How do we include related fields in a rbf_selectQuery select query.

 Forum

How do we include related fields in a rbf_selectQuery select query.

This question is answered

Hi Team

Please confirm how I can include other fields from related tables into a single rbf_selectQuery select query?

if I do

rbf_selectQuery("SELECT name, R267698753 FROM TestObject1", 20000, buildData);

the related R267698753 returns the ID for each related R267698753. I want to return other fields of this object. The relationship is many to one.   I.e. many TestObject1 can only have one R267698753.

So I want to return 'name' field from R267698753 in my select query from TestObject1.

Left joins or object alias do not seem to work like TSQL queries.

So how do we accomplish including related data in a rbf_selectQuery select query

My code :

<div id="grid" style='width:100%;'></div>

<script>
  rb.newui.util.addEventListener("rbs_pageRender",function(){
 
    function buildData(values){
      debugger;
      var gridData=[];
      if(values){
        for(var i=0;i<values.length;i++){
          var data={
            name:values[i][0],
            R267698753:values[i][1]
          }
          gridData.push(data);
        }
        generateKendoGrid(gridData);
      }
    }
 
    function generateKendoGrid(gridData){
      var dataSource = new kendo.data.DataSource({
        data:gridData
      });
      var kendoGrid = $('#grid').kendoGrid({
        columns:[{
          field:'TO1.name',
          title:'TestObject1 Name'
        },{
          field:'TO2.name',
          title:'TestObject2 Name'
        }],
        groupable: true,
        dataSource:dataSource
      });
    }
 
    rbf_selectQuery("SELECT TO1.name, TO2.name FROM TestObject1 AS TO1 LEFT JOIN TestObject2 AS TO2 ON TO1.TestObject2id = TO2.id", 20000, buildData);
  });
</script>

Verified Answer
  • Ah I got it. I have to create related fields in my object which are read only. I can just reference them in the select query.

All Replies
  • Ah I got it. I have to create related fields in my object which are read only. I can just reference them in the select query.