Restrict CRUD list based on logged in user

Hi,

I am wanting to restrict/filter an EntityCRUD component to only display those items that are owned by the currently logged in user.

In the model it is specified that a user (ServiceCommissioningBody) can have one to many Services. On a services page I have the EntityCRUD as follows:

<EntityCRUD
      {...this.props}
      modelType={ServiceEntity}
      URLExtension="13053bdd-361f-49f9-831b-0126368492f2"
       // % protected region % [Add props to crud component 13053bdd-361f-49f9-831b-0126368492f2 here] on begin
       removeModifiedFilter={true}
       removeCreatedFilter={true}
       // % protected region % [Add props to crud component 13053bdd-361f-49f9-831b-0126368492f2 here] end
 />

Sorry for the late reply, you can get that functionality by sending an additional prop through to the collection component. For example:

<EntityCRUD
    {...this.props}
    modelType={ServiceEntity}
    URLExtension="13053bdd-361f-49f9-831b-0126368492f2"
    // % protected region % [Add props to crud component 13053bdd-361f-49f9-831b-0126368492f2 here] on begin
    removeModifiedFilter
    removeCreatedFilter
    entityCollectionProps={{
        conditions: [[{
            path: 'owner',
            comparison: 'equal',
            value: store.userId,
        }]]
    }}
    // % protected region % [Add props to crud component 13053bdd-361f-49f9-831b-0126368492f2 here] end
/>
1 Like