UIB AJAX call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I’m working on a technical dashboard in UIB that includes a client script. I have a simple requirement: retrieve all child project IDs for a given parent project.
I created a data resource and bound a client state parameter to the condition. However, when I try to access the returned IDs from the data resource in my client script, I’m getting nothing back — the data resource appears to return an empty object.
Has anyone run into this before or knows what I might be missing?
Thanks!
- Labels:
-
Yokohama release
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you share your script here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Things I would check:
1) did I add the execute ACL to the data source? You should see any data returned at the DS level when clicking on the data source
2) Use logging within the data resource script on the final return object to see what is passed over
3) Try a default client state parameter that you sure are working
4) Check the syntax on the client script, most stuff there works as an object (make a log to the console about the object (console.log works here))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
const projectFilter = appliedFilters.find(f => f.label === "Project");
const currPrjValue = projectFilter.values.toString() || "";
// Update parentId state first
api.setState("parentId", currPrjValue);
// Explicitly refresh the data resource and handle the result
api.data.child_projects.refresh();
// Update parFilters state
api.setState("parFilters", ({ currentValue }) => {
const { parFilters, encodedQueries } = mergePARFiltersV2(
currentValue,
appliedFilters
);
api.setState("encodedQueries", encodedQueries);
return parFilters;
});api.data.child_projects.results does not return any value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
okay, a couple of things. According to the documentation https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...