Display data from two masters within a single data grid

Adam Grossman shared this question 6 years ago
Answered

I would like to display information from two data masters within a single data grid.


For example: I'm dealing with tasks related to a vehicle. The vehicle information (make, model, description, etc.) is contained within one data master "vehicles" while the task information (title, due date, assigned to, etc.) is in a second data master "Tasks". The "related to" field from the tasks keys to the "description" field from vehicles.


I would like the data grid to display the list of tasks with some information about the vehicle the tasks relates to.


If necessary I could load a second data grid within the main one just for those fields but that would limit field placement and I'd like to avoid it.


Is this possible?

Comments (4)

photo
1

In the tasks data grid add another column and drag a label or a text inside. Then select it and go to the events tab. There create an 'on page load -> set value' event. As the value, build this expression:


select( filter('DM Vehicles', vehicles.description= (select(row,tasks.related to) ) , description)


That expression looks for the vehicle that has the same description as the one in the attribute 'related to' in the task in that row. Then, once it has the vehicle, it selects the description. And that would be the value of the text.

photo
1

This works great! Thanks Victor.


A couple of notes for the rest of the community.


select( filter('DM Vehicles', vehicles.description= (select(row,tasks.related to) ) , description)


DM = Data Master


select( filter('DM Vehicles', vehicles.description= (select(row,tasks.related to) ) , description)


row = the row from the data grid in the screens tab of the expression builder


select( filter('DM Vehicles', vehicles.description= (select(row,tasks.related to) ) , description)


description = the column that you want returned. If I wanted to know the mileage of the vehicle then I would drag the vehicles.mileage to that box

photo
1

This was working perfectly and then it stopped for some reason. All of the fields that were using a version of the formula above started coming out as undefined. I copied and pasted the interaction code into "on click" as well as "page load" and it worked fine after clicking on it.


Any ideas why this would happen and how I could fix it? I had another issue that seemed to be associated with the load order on a page, is there any way to manipulate that?

photo
1

The load order of the events can be manipulated if you create all of them in the screen instead of each component.


The thing about the undefined values could happen if you copy an expression from one page to another.