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.

I need help returning two values (tableName and query) to update client-state parameters UI Builder

Sathwik1
Tera Expert
I need to update two client-state parameters—tableName and query—when clicking on a data-visualization item in my UI Builder. I’m not sure how to correctly return and assign multiple values. I attempted some code, but it isn’t working. Can someone help me with the proper syntax?



/**
* @param {params} params
* @param {api} params.api
* @param {any} params.event
*/
function evaluateEvent({
api,
event
}) {
var query = event.payload.params.query;
var table = event.payload.params.table;
console.log("query " +query);
console.log("table " +table);
return {
updates: [
{ propName: "queryParam", value: query },
{ propName: "table", value: table }
]
};
}

@Ankur Bawiskar 

10 REPLIES 10

Sarthak Kashyap
Mega Sage

Hi @Sathwik1 ,

 

I tried your problem in my PDI please check below screen shot and script 

 

If you want to give dynamic props from script 

please follow below syntax.

var query = 'active=true'

api.context.props.query(query);
 
 
SarthakKashyap_1-1763150281534.png

 

You can also find this thing from official docs from ServiceNow 

SarthakKashyap_2-1763150354306.png

Link

 

Let me know if you need more help!

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

 


 

Thanks Sharath for your reply.. but what should I pass in the simple list component.. for table and filter? will it automatically set?

 

My requirement is.. In First column I want to show two Data Visualization.

One for Incident, another for problem.

 

Now in second column I want to show one simple list.. based on selection in the data visualization those records needs to show... So I'm trying to set client state parameters so that these client State parameters I can call in simple list table and filter part..

 

@Sarthak Kashyap can you please confirm if your suggested solutions works here?

Hi @Sathwik1 ,

 

Sorry for late reply, you have to create a client script and call that client script on body event, when load is ready. So when ever you loads a page, your client script will execute and your props will set.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

Sathwik1
Tera Expert