- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 08:56 AM
I have created a catalog with 3 fields and i have 1 onLoad script and 1 onChange script , in onLoad we do a REST call and get the data but i have to use a portion of the same data in onChange as well is there a way to store the REST call data in an object and access it across or is that a way i can set the whole data in g_form somehow and then resue it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 09:55 AM
It should be string and you can mention the size as 5000.
for storing the data use g_form.setValue('DATA', JSON.stringify(response));
for getting the same data use : var data = JSON.parse(g_form.getValue('DATA'));
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
02-22-2023 09:18 AM
@kiwi07 ,
1) Create a new variable lets say "DATA" and make it hidden using the UI policy or on load client script (g_form.getDisplay('DATA','false')) and when you made API call into on load client script store the data into "DATA" variable using g_form.setValue('DATA',response_from_API_call) and get the value into onchange client script using g_form.getValue('DATA') and use i accordingly.
2) Second way is 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
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
02-22-2023 09:29 AM
@Prince Arora what should be the type of "DATA" variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 09:55 AM
It should be string and you can mention the size as 5000.
for storing the data use g_form.setValue('DATA', JSON.stringify(response));
for getting the same data use : var data = JSON.parse(g_form.getValue('DATA'));
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.