Filter data source by an entity's field of type relationship

Hello!

I have an issue when trying to get further information form a relationship field from Data Service in UiApps.

In the example below, an user is linked to its nutritionist (here this relationship has the name NutritionistId), but in Apps I need to filter a table in order to get the logged nutritionsit’s users.

This means that I should have been able to type/choose this option : [User.NutritionistId.Id “=” CurrentNutritionistId], but it seems impossibile.

Hopefully, you’ll give me a solution for this.
Many thanks!

image

1 Like

Hey @Irina_Butu

So you mean the filter with data service in apps is not working as expected of the comparison based on a relationship field ?

Thanks
#nK

Yes, that’s right. It seems that I can’t reach the particular fields of a relationship field. If I tried to do that in Studio, it would perfectly work, but not in UiApps.

1 Like

Hey @Irina_Butu

It’s possible but only with GUID.

image

This was giving me results.

Thanks
#nK

Yes, but that’s a shame, because we cannot use the relationship between entities at all.

In real life matters, there will be a lot of cases when an aplication will need to go in further details using these relationship fields.

ex. In some cases I might want to show the name of an user’s nutritionist, but as you say, I will never be able to retrieve it directly using User.Nutritionist.Name in UiApps…

1 Like

Hey @Irina_Butu

Yes, But I believe it should be coming soon in future release.

As of now I guess you can try doing kind off nested querying to fetch the same.

Thanks
#nK

1 Like

@Irina_Butu ,

I understand that you have two entity and those are having Relationship and you want to get the data based on relationship.

If yes , you can achieve this functionality, for that you need to define your ER into correct approach.

Please follow below.

  1. Create an entity as example Leave Request

  2. Create an another entity leave type.

  3. Create a new field into entity as leave type.

  4. Select the relationship as below.

    1. Type - Relationship
    2. Related Entity - ** As you wish
    3. Related Entity display Field - ** As you wish
  5. Save the Field

  6. Add records into Entity.

  7. Now go and add your entity into App

  8. Once you add your entity all the relationship entity will get added by default.

  1. Now go to your table list into Data source and add the Filter expression as below.
    image

  2. If you add the Relationship all the mapped display field will get added default and you can show into table or do any operation on the field.

  3. In my case I added relationship of entity and I can filter relationship entity record default here.

So by defining correct relationship of entity you can get the details. But if you are trying something like SQL where you can do some LEFT, Right all join and get the details that is not possible right away into Filter.

Hope this will help you.

Please mark this as solution if you are satisfied.

Thanks,
Arvind

Thank you for the detailed explanation.

So, as a recap, the relationship field in Apps only allows me to get acces only to that specific field - in your case Type of LeaveType. I cannot acces any other fields of LeaveType through this relationship. Maybe I should rethink how to get the data I need, or maybe add more fields of relationship type for direct filtering in Apps, though I don’t know if this is good practice, as it leads to duplications.

It is still a bit confusing and disappointing because in Query Entitiy Activity in Studio, you can go further and fetch other fields coming from the relationship field - like a join in relational db as you said.

For now, seems that I should stick to process work and not rely that much on direct Apps capabilities for in depth filtering.

Many thanks & best regards!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.