Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to store rest API JSON response in cache in ServiceNow

dgarad
Giga Sage

 

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?

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad
6 REPLIES 6

Hi @Prince Arora 

 

can I use below code in scheduled jobs is running daily . after storing in session how i can use in data on widget 

var session = gs.getSession();
session.putClientData('data', "your data")

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

@dgarad 

 

If you only want to save the value for a few minutes because this is saving the data in the user's session, which is only available while the user is active in the session, you can use this method; otherwise, don't use it if you want to store data for a day or so.

 

I have already explained in my last reply how we can get the data

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.