UI Builder Script Data Source - Set Color Rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 08:13 AM
Hello!
I need to come up with a script to set a custom single color rule for a Single Score Interaction on UI Builder. But I didn't find any documentation about the necessary data to return in the evaluateProperty function.
My goal is to be able to set a color rule based on the data source (also scripted) count output I have for my single score interaction.
Single Score Interaction Data Source Script:
function evaluateProperty({api,helpers}) {
// Query CoE
var coeList = api.state.listSysIdCoE;
var coeQuery = "";
coeList.forEach(function(sysId, index, coeArray){
coeQuery += "u_service_offering="+sysId;
coeQuery += (coeArray.length - 1 != index) ? "^0R" : "";
});
//Query concatenation
var strQuery = "stateNOT INclosed_complete,closed_abandoned^"+ api.state.strQueryAssignment + "^" + coeQuery + "";
console.log(strQuery);
//Output
var data = [{
"isDatabaseView": false,
"allowRealTime": true,
"sourceType": "table",
"label": {
"message": "Interações em Aberto"
},
"tableOrViewName": "interaction",
"filterQuery": "" + strQuery + "",
"id": "dataInteractionID"
}];
return data;
}
Metric Script:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({
api,
helpers
}) {
//Metric Configuration
var metric = [{
"dataSource": "dataInteractionID",
"id": "METRICID",
"aggregateFunction": "COUNT",
"numberFormat": {
"customFormat": false
},
"axisId": "primary"
}];
return metric;
}
if I use the static input of the color rules (for single color option), something happens with the data comparison of the data source output and the color rule, which causes the single score output to be "--";
So I need to find a way to manipulate the data output from the data source, or manage to compare it correctly through the color rule using a script.
Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 10:04 PM
Hi @Lucas Occhiutto ,
please use the "debugger" in the data source script and check what are you getting for
api.state.strQueryAssignment
and
coeQuery
While building "strQuery" you are directly using the api.state.strQueryAssignment, and not checking this to any field value. I hope this state parameter is return value in this format "type=chat", if not update the query parameter correctly to get the right data.
Let me know if it helped.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 01:10 AM
@Nootan Bhat Thank you. How can I find documents regarding scripted data source and metrics. I need the script for data source with indicator type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 01:18 AM
@Lucas Occhiutto Thank you. How can I find documents regarding scripted data source and metrics. I want script for data source with indicator type.