Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Hi @scottl ,

 

Maybe a little late to the party here but thanks to your example I did get this to work as follows (I'm on a page with a form controller):

 

 

function evaluateProperty({
    api,
    helpers
}) {
    return [{
        "label": api.data.controller.displayValue,
        "id": api.data.controller.sysId,
        "value": api.data.controller.sysId,
    }];
}