Question about UI Builder Script Includes (UX Client Script Includes)

Daniel Plunket1
Tera Contributor

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

1 ACCEPTED SOLUTION

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 } }

 

View solution in original post

5 REPLIES 5

Dibyaratnam
Tera Sage

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?

Basically, I'm passing in a JSON client state parameter into the script include. The JSON Object is formatted like this: 

"JSONObject": {
    "Low"false,
    "Medium"false,
    "High"false
  },
 
I want the script include to set 2 of the elements to true and then return the updated object back to the client side. Hopefully this helps.

Dibyaratnam
Tera Sage

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.

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;