How to filter multiple models from a 'global' UI only User object lookup field, where each model has

I have a page that shows Case object records, and have 3 models each with different conditions. There are 3 tables, one displaying records for each model.

I want the ability to create a UI only style user text field (where I can start typing a user’s name) at the top of the page, so I can select a user, and then automatically filter all the 3 models (and subsequently tables), where the OwnerId is the selected user.

Understand a filter per table can be added easily, though I also want to expand this in the future, e.g. have the user select function at the top of the page, then multiple tabs underneath, all filtered based on the selected user.


Action framework for the win! 

Here is a sketch of something you could do. 

1.  On the three models that look up to user add conditions on the user object that are filterable default off. 

2.  I would not use a UI Only field, but rather create a model on an object that looks up to use.  The model should “create a new row” and not “load data.”   This model will drive the filter control.

3.  Put a field editor on your page,  in edit mode.  Add the user lookup field to the page. 

4. On the user lookup model add a Model Action.  The triggering even should be “changes made to the user field”   The action sequence should activate condition and set value - for each of the 3 conditions you made in step 1.  (The value to be passed will be UserId).  Then requery the models. 

This should work. 

You might also use the search component,  and build a search on the user object and bind the action framework sequence described above to the click event… More options…  

Hi Rob

1- I’ve added a condition where field OwnerId is [what value do I add?] condition is filterable default off.

2- What do you mean by ‘an object that looks up to use’? Would a custom object with one field lookup to user work, assumably it is just part of the filter ‘structure’ rather than actually needing data/relationship with records that need to be filtered etc?

Thanks

Dan

Hi Rob

Thanks - this is great, actions are awesome…

I got this working by creating a custom object with one lookup field to user object. All works as per your instructions - one additional idea that I nearly have working:

How to save the user that the logged in user last selected… (so when they refresh page, they don’t need to reselect user every time). (Note - ideally we would refresh the page every min automatically, is this possible? Or automatically refresh page if a row is added or changed that has been loaded - again couldn’t see anyway to achieve this in community or help site…?) 

I tried to achieve this by loading 1 row of the model data where CreatedById is the running user, and pulling in the UserId (only field on the SkuidUserFilter__c object). This works in the sense it prefills upon page refresh into the “User” field I added, though it doesn’t activate the conditions, only updating the user triggers it.

I also tried to default condition on, and also tried to not use the action to set and activate condition, but instead create a model condition: case OwnerId is SkuidUserFilter model “UserId” of the 1 looked up record - neither of these seemed to work.

Ideally when user loads page it would find the record with their choice, and they can update and click “Save” at any stage, which will update SkuidUserFilter__c record and on page refresh would default to the (effectively) last selected user.

Dan


Hi Rob 

Any feedback on this one?

Dan

These are all good questions. 

You are on the right track with allowing the user to save a record to your custom object with the value they want to see in the user filter.  Here are some ideas. 

1. I would use a model condition to set the default user value on your multiple models. 
2. For this to work you need to ensure that your custom object model is BEFORE all your other models.  The data has to be loaded in order to be effective in Field From Another Model conditions. 
3. We’ve done a lot of work on FFAM conditions in the last release and I’ve not tested it exhaustively.  But I think that if you simply change the value of the user on that one row you have exposed and then requery all the underlying models - they will pick up the new values. 

If this does not work…

1. You will probably need to add another condition on each of your multiple models.   One condition is the FFAM condition that is “Filterable default on”  Another condition is set to a blank value and is “Filterable default off” 
2. The action sequence that is triggered when you update the user field needs to do two things to each model.  Deactivate the FFAM condition and Activate and Pass value to the second condition.   

Hopefully this works for you.

About refresh.  This topic has some pointers for time based polling.  

https://community.skuid.com/t/real-time-dashboards?topic-reply-list%5Bsettings%5D%5Bfilte…



Hi Rob

I gave this a go by:

Moving the SkuidUserFilter custom object I created to the top of the models list, set it to Load model data on page load (true), Max 1 row, sort by CreatedDate DESC and condition was that the custom object record was created by logged in user. It brings back the User__c lookup field on that record. 

- So this should then mean that the SkuidUserFilter object I created has loaded the User__c value correctly. I can see this works as the field editor has the last selected user in it.

Only issue is that it appears not to be taking this condition into account on the next models BillingModel (and instead loading all data, not applying the condition of User__c) - the BillingModel looks up Billing__c rows where one of the conditions is a custom user lookup field on the Billing__c object model is the value of the User__c field returned from first row in SkuidUserFilter model. 

The BillingModel User__c condition was Filterable default off (turned on by SkuidUserFilter model action when “Row in model updated”). This does work when you update the user, though when the page first loads, even if a record is pulled in, it isn’t applying the filter. To solve I looked to (1) add an action intiating event to the effect of loading in a new row (or for the first time), couldn’t see this kind of option, and (2) I turned the BillingModel condition to Always On.

Any thoughts on what may not be working?

On another note, to achieve an easy refresh I added a page title with a button that shows a popup and blocks UI, then re-queries models and unblocks UI. Works well and refreshes all models effortlessly without needing to refresh page and lose context and wait for it to reload.

Dan