The CreatorCon Call for Content is officially open! Get started here.

Automatically add filter to reference variable?

kim-lindgren
Kilo Sage

When I create a catalog variable that references the user table, I always want to have certain filters in place, such as "Active is true" and "User ID is not empty". I also have a particular variable attribute that should always be added.

 

Can this be done automatically? In other words, can you create a script to add all the filters and variable attribute as soon as you select the User table as your reference table?

 

kimlindgren_1-1698674446253.png

 

Best regards,

Kim

 

2 REPLIES 2

Jace Benson
Mega Sage

Sure!  Client scripts and UI policies would be how to do that on client.  When Reference is set, if value is `sys_user` then g_form.setValue('field','your filter or attributes');

I know how to use client scripts and UI policies on a catalog variable. But how to use them on a form? Where would the client script live and how would it know to target that "Reference" field in a variable of type Reference, and how would it create the filters who aren't there to begin with?

 

Perhaps a simple example would do. I'm very familiar with client scripts and UI policies in a catalog item, but not outside of it.

 

Thanks.