- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi
I'm trying to use some scripted data resource in UI Builder for a report (data visualization - type: vertical Bar). I've tried many and I have the following findings:
- if I use "Add data manually" and paste a JSON with the data that I want to display it's working fine and data is visible in the report
- if I add the desired output in the script source it's not working and I receive an error "Cannot convert undefined or null to onject"
This is the script that I'm trying to use (hardcoded output)
Any ideea what could be the issue?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You are binding to the incorrect property, you want to tick the "define data manually" and then use the data property that will be shown below it.
Data sources would be an array of tables or indicators
Now Component Library | ServiceNow Developers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Your script seems to work fine for me. Where are you trying to use it? And where is the error showing up, is it in the console? If it's in the console it should give you the sysid of the sys_ux_client_script record. Is it the one you expect?
function evaluateProperty({
api,
helpers
}) {
const output = [{
"data": [{
"priority": "1 - Critical",
"value": "28"
}, {
"priority": "2 - High",
"value": "12"
}, {
"priority": "3 - Moderate",
"value": "9"
}, {
"priority": "4 - Low",
"value": "9"
}, {
"priority": "5 - Planning",
"value": "6"
}],
"metadata": {
"dataSourceLabel": "Incident",
"eventData": {
"table": "incident"
},
"groupBy": [{
"id": "priority",
"fieldType": "integer",
"label": "Priority",
"series": [{
"id": "value",
"type": "value",
"label": "Incident"
}],
"elements": [{
"eventData": {
"query": "priority=1"
},
"id": "1",
"label": "1 - Critical"
}, {
"eventData": {
"query": "priority=2"
},
"id": "2",
"label": "2 - High"
}, {
"eventData": {
"query": "priority=3"
},
"id": "3",
"label": "3 - Moderate"
}, {
"eventData": {
"query": "priority=4"
},
"id": "4",
"label": "4 - Low"
}, {
"eventData": {
"query": "priority=5"
},
"id": "5",
"label": "5 - Planning"
}]
}],
"format": {
"unitFormat": "{0}"
},
"aggregateBy": 4
}
}];
return output;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello
I'm trying to use the script as a data source for data visualization in UI Builder
And yes, error is in the console. Maybe the format that I'm using as the output is not correct, but I wasn't able to find another structure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You are binding to the incorrect property, you want to tick the "define data manually" and then use the data property that will be shown below it.
Data sources would be an array of tables or indicators
Now Component Library | ServiceNow Developers
