Applying a default value to a table filter that is based on reference field

I hope I am completely overthinking this and that there is an easy & obvious answer :slight_smile:

Use Case - When a page that contains a table loads, I need to be able to apply the “Current User Id” as the default filter value on a table (e.g. List Accounts Where Where OwnerId = $User.userId).  The filter field needs to be searchable and provide an “All” options as well.  In short, the records are filtered initially by the current user but the user can change the filter value and has visiblity to all “Users” in the system for searching as well as the “All” option.

Question - Is there a way to declaratively achieve this?

Things I’ve tried:
1) Looked for a way to apply a default value to an automatic table filter - No dice
2) Tried using a manual filter who’s default condition value is the current UserId but model conditions with “Specific Value” don’t apply merge syntax and treat the value as a string literal
3) Tried using a combination of conditions and models and the “Add Effect” feature of table filters to turn off/on different conditions but no dice

Am I overlooking a declaritive way to do this or is javascript the only answer?

I’m not sure if you’ve tried this, but have tried setting the condition the current user and setting this condition as “Default On”? This way the filter can override when chosen by the user.

Hey Pat - Thanks for this.  Yeah, tried that.  The problem is that to do that, you have to use either the “User” merge property or “Field from another model” property.  The table filter needs “Specific Value” so they don’t work together as needed.  You could have two conditions and deactivate one when someone searches in the table but then the search field itself in the table won’t show the users name on page load because it’s two different conditions.  Since you can’t use merge syntax in a model condition of Specific Value, you can’t use it that way either other than a JS based solution. 

Maybe I’m overthinking?

Do you have Name in the model that’s providing the User Id? I’ve seen including this make a difference when creating new records with Default Lookup values.

Yep, Name & Id in the model that is being used as a source.  

The challenge I’m having is getting the current User Id in to the condition on the Account model.  You can’t use specific value to do this but the table filter must be applied against a condition set to "Specific value."

Only thing I’ve come up with is a JS solution and while it works, doing something this trivial shouldn’t require JS :frowning:

I would cheat and put two versions of the table in a tab set set to picklist. I would name the first tab “My Records” and name the second tab “All Records”. I would put Table 1 in tab 1 and set the table to Model 1. I would put Table 2 in Tab 2 and set it to Model 2. I would set a condition on Model 1 to be only owner=current user. I would put a multi option filter on Table 2 on the owner field. Then, if it didn’t work, I would ask you for that neat JS solution! :wink:

Creative solution Raymond.  That actually would technically work I believe.  That said, I think your users must be a lot more forgiving than mine - mine would scream and yell at having to go to two places for the same data :slight_smile:

And then I’d scream and yell cause I have two table configurations to maintain lol

Queue Up - Reusable comments plug - Vote here - :)

Haha… The things I’ll do to avoid learning JS!

and I voted for your cloning components… I would LOVE that.

Yeah, being able to reuse a component configuration would rock and be something I think lots of people would find significant value in.

My pages are so complicated that without “re-use” there’s no way we’d get the app off the ground.  For example, I need to show the same “field editor” in 3 different places on the same screen.  The field editor is incredibly complex with search fields, filters, conditional rendering, etc.  I’ve built a custom solution to “re-use” a component but it has limitations.  Having this feature in the core product would be groundbreaking IMHO.

Skuid Team - Any way to accomplish this short of a JS solution?


I don’t know if this is ok for your use case, but you can add a tab and place your table inside of the tab.  Then add a tab action when the tab is first shown to set your filter to the current user.  This allows the user to change it from then on.



Hey Bill -

Very creative, love the idea!  In my case, I ended up going with a JS based solution and it’s working as needed.  Still, seems to me like something that should be available without the need for JS and/or creative declaritive solutions such as the one you proposed.

I created a few posts to ask for these features.  Feel free to vote if you agree :slight_smile:

  1. Applying a default value to a table filter that is based on reference field
  2. Manual filter source using rows from model should requery model on search
  3. Apply default value for automatic table filter
  4. Support merge syntax on model condition specified value(s)