how to query related data by using a foreign key

submitted data to the 2  different tables  by using process model write to  database, where 1 data type  PK  is the FK  for second table. but I can't use both the  tables in record type, and in summary view, I don't know how to query data  form the to fields by using a foreign key... ... please  explain about how query related data from database ,when i have a foreign key column..,( apart from creating a view in database, please suggest me how to do it in expression rule ) .

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    The interface rule for your Summary View would likely have a rule input for the primary key of the table the record type is referencing (or at least, it should).  You would then use Query Entity calls / rules to load data from related tables (such as any rows containing your current record's primary key as a foreign key) into local variables in your interface, then do with those whatever you like (generally, displaying via various methods as your design dictates).

    Similarly, if the table for your record type has foreign keys itself that point to other tables (so basically the reverse of the above), you would merely look up those rows from those other tables using query entity, again into local variables that you can refer to later in your form.

  • 0
    A Score Level 1
    in reply to Mike Schmitt

    Thanks for the  information,

    a!localVariables(
      local!marks: a!queryEntity(
        entity: cons!APM_DSE_Marks_Constant,
        query: a!query(paginginfo: topaginginfo(1, - 1))
      ).data,

    local!markssheet:index(local!marks,"studentId",null),
      local!find: find(ri!marksforparticulastudent,local!markssheet),
      local!indexeddata:index(local!marks,where(local!find)),
      local!indexeddata
      )..........

    this is how i return the written the expression rule to get the data of marks   for specified student id (PK/FK),

    is there any better approach.?

  • 0
    Certified Lead Developer
    in reply to Bellam

    you'll want to use query filters to query only the row(s) you want.  Currently you're querying every row and then trying to pull out just the matching rows, which will work fine if your DB table has 5 test rows in it, but will get very problematic or just not work when you're working with a realistic-sized DB of hundreds, thousands, or more rows of data.

  • 0
    A Score Level 1
    in reply to Mike Schmitt

    thanks for the suggestions .it helped