We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

Daniel Plunket1
Tera Expert

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

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