- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 12:23 PM
Hi Community
Please advise how I can make condition with bind data for data source for single score.
There isn't such options there.
I need to get locations from @Data.look_up_user_preferences_1.result.location
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 09:00 PM
In the metric use this code:
function evaluateProperty({api, helpers}) {
var metric = [
{
"dataSource": "DVID",
"id": "METRICID",
"aggregateFunction": "COUNT",
"aggregateField":"",
"numberFormat": {
"customFormat": false
},
"axisId": "primary"
}
];
return metric;
}Aggregate field is not required as its a single score and not charts are used.
Let me know if it helped.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 08:16 PM
Hi,
What do you mean by single score here. Are you using Data Visualization component here. More details on this are going to be helpful.
ServiceNow Community Rising Star 2022/2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 02:54 AM
Hi,
Yes, I use Data Visualization component.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 04:00 AM
Hi @Nadia7,
You can't use the dynamic values in data visualization filters. You have to use script or parFilters.
1) You can use the parFilters. Refer: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1156652. Tried it in PDI and it works.
2) Or else you can use the scripts in your data visualization.
Below are the sample script(use the appropriate values in the script):
function evaluateProperty({api, helpers}) {
var data = [
{
"isDatabaseView": false,
"allowRealTime": true,
"sourceType": "table",
"label": {
"message": "LABEL OF YOUR DV"
},
"tableOrViewName": "TABLE_NAME",
"filterQuery": "YOUR_FILTER"+api.data.look_up_records.result , //you can build your query here using dynamica data binding.
"id": "DVID"
}
];
return data;
}
Metric use below code:
function evaluateProperty({
api,
helpers
}) {
var metric = [
{
"dataSource": "DVID",
"id": "METRICID",
"aggregateFunction": "SUM",
"aggregateField":"FIELD_NAME",
"numberFormat": {
"customFormat": false
},
"axisId": "primary"
}
];
return metric;
}
In Group by use below code:
function evaluateProperty({
api,
helpers
}) {
var groupby = [{
"maxNumberOfGroups": "ALL",
"numberOfGroupsBasedOn": "NO_OF_GROUP_BASED_ON_PER_METRIC",
"showOthers": false,
"groupBy": [{
"dataSource": "DVID",
"groupByField": "FIELD_NAME",
"isRange": false,
"isPaBucket": false
} ] //can use multi 'group by' by adding another object
}];
return groupby;
}
This way you can filter the data the way you want. For field, query etc use the state or data parameters to bind the data dynamically.
Please let me know if it worked for you.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2023 07:37 AM
Thank you @Nootan Bhat ,
I am trying to do it with script, but I get an error. Maybe you can help me with it?
