- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2024 10:52 AM
I have a question on UI builder script includes. I'm currently working on a script include that has a function where I'm passing in a JSON parameter with 3 elements. What I want to do in the function is set the value of each element in the JSON parameter and return it. Has anybody done something with JSON objects in a script include and be willing to share an example showing the proper syntax?
Thanks
Solved! Go to Solution.
- Labels:
-
UI Builder : Next Experience
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 10:25 AM
I don't see anything wrong with your code but still you can refer below sample code. It should help.
var jsonObj={ "JSONObject": {
"Low": false,
"Medium": false,
"High": false
}};
console.log(jsonObj);//{ JSONObject: { Low: false, Medium: false, High: false } }
if(true){
jsonObj.JSONObject["Low"]=true;
jsonObj.JSONObject["Medium"]=true;
}
console.log(jsonObj);//{ JSONObject: { Low: true, Medium: true, High: false } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 09:40 AM
This seems as a javascript problem and nothing to do with any specific script include. Can you share the JSON and also share how you want the elements to return?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 09:56 AM
Basically, I'm passing in a JSON client state parameter into the script include. The JSON Object is formatted like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 10:04 AM
And what is the issue you are facing here. Is the JSON which you are returning, doesnt contain what you want. What is the code you have written to set the elements to true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 10:19 AM
I guess I'm looking for assistance on what the proper syntax would be on updating the JSON elements. I'm trying to create a function that can be re-used in multiple UI builder pages.
From a code standpoint, what I have so far is something like this:
if( condition == true){
jsonOBJ.Low = true;
jsonOBJ.Medium = false;
jsonOBJ.High = false;
}
return jsonOBJ;