How to store rest API JSON response in cache in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 11:30 PM
We have a requirement to update the cards on portal, for that we are using count. We get the daily visited count for the cards from external source. Our requirement is to update the cards based on the count that we received.
We have one approach - creating custom table, for storing this count. We created cards records in that table and daily we are just updating the count in that table.
But our seniors are not agreed for custom table.
Instead of custom table. They suggested us to use utility to store the data in cache. And use the data in widget.
How to to build the utility for cache?
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 12:19 AM - edited 04-18-2023 12:21 AM
you can store data into window's session:
sessionStorage.setItem("Data", response_from_API_call); // storing data into the session
var data = sessionStorage.getItem("Data"); //getting data from the session
Can you take a look below thread, I have answered same type question earlier!
Link1 //please check first this
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 05:12 AM
Have you looked at the solution?
Please mark it as accepted if it has answered your query!!
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 11:46 PM - edited 04-19-2023 11:47 PM
can we use sessionStorage serverside script.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 12:14 AM
for server side script please use:
for storing:
var session = gs.getSession();
session.putClientData('data', "your data"); //!!!! IMPORTANT need to pass string
for getting:
var session = gs.getSession();
session.getClientData('data');
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.