Is it possible to dynamically assign the default value of a filter in UI Builder?

Kyle Pasmore
Tera Contributor

Hi,

I am building a home page in UI builder with some reports that need to be filtered by location. 

 

I am wondering if it's possible to dynamically assign this default value in the filter to be the same as the users locations.

I should be able to grab the current users location with a client script and update a client state parameter with the location. But I'm not sure how to get this value into the default value of the filter.

 

Any ideas would be great? 

Thanks in advanced

5 REPLIES 5

scottl
Kilo Sage

Is there any update to this as I'm trying to achieve the same thing.  Did you find any documentation showing how to dynamically set default values?

[Update] using the Script field for the Default values, you can return an Array and it will show that two records were found for the filter however am unsure of what data type the array indexes need to be and if an object, am unsure of the key value pairs. In this state it also breaks the loading of the filter's list and doesn't add anything to the selected column either.

[Update]  Setting Filters to selected values in the multi-select use the following JSON format.

 

 

 

[
	{
		"label" : "Group",
		"id" : "ServiceNow Admin",
		"value" : "as67d5a76sdra67rd76asrd76aads78"
	}
];

 

 

 

 However, still cannot figure out how to populate that dynamically based on the User.  Cannot understand how to use Data Resources to look that data up dynamically either as the "conditions" field is missing? Cannot take the data from a Data Resource and build the above object in the script field of "Default values" field either.  If the conditions field is intentionally missing and we're to use the Record field to find records where are the examples on how to complete a basic query through that?

Why is this so difficult or am I missing something, or am I trying to do something that's not possible? 

[Update] Have created a Transform Data Resource to transform the Lookup data into an object formatted above and tried to bind the Default values field of the filter to this transform data resource, and it doesn't work.  However, if I take the output of the data resource and hardcode it into the Script field and return that array of values it works!

Anyone know how to get the Default values field to work with Data binding?