05-29-2023 06:38 AM
Hi Team,
Can you guide me how to create a JSON in UCCX script.
Regards,
Jijesh
Solved! Go to Solution.
05-31-2023 06:33 AM - edited 06-04-2023 06:30 AM
You need this.
I already have shared a screenshot with this. Do you not read what is shared with you?
05-31-2023 08:00 AM
I have updated the script and run the debug. Now I am getting the below results
Status Code below
Below variables which I created for this script
05-31-2023 08:38 AM
So what is your issue? The JSON doc is from what I can tell populated with the response that you get from the Rest call. If it is not returning what you expect you're doing something wrong in the Rest step. It could be as simple as your using the wrong request URL.
05-31-2023 09:24 AM
Let me check the Url and retest it
06-01-2023 03:51 AM
If I run this in our system and do the query we have defined and the resulting output that our ServiceNow platform has we get this result.
Content of the string with the response.
Content of the JSON document.
By this as what you see in your response is only U"{\"result\":[]}, so that's why you only see that in the JSON doc. What have you defined as the expected response from ServiceNow when you do the REST call? I know our SN admins defined what to include in the response.
06-03-2023 11:11 AM
sorry for the delayed response.
I have added the url parameters in Rest Call and created the JSON document ,responses.
I am getting the JSON response please see below.
U"{\"result\":[{\"user_name\":\"200065\",\"u_empgrade\":\"C2\",\"vip\":\"true\"}]}"
I tried to match vip value to route the calls nothing worked. Kindly suggest.
06-03-2023 11:57 AM - edited 06-03-2023 11:15 PM
If you look at the picture I shared earlier of our script you should be able to see how to do that without too much effort. You’ll need read it as “result.vip” from the JSON document based on your output. This would give you the value “true” based on what you shared.
06-03-2023 12:15 PM
I have created the result and response string. Unfortunately getting the null value.
06-03-2023 12:52 PM - edited 06-03-2023 11:17 PM
Please share a screenshot of the read JSON step. By your description it sounds like you don’t do the read from the JSON document right or maybe not at all.
This part in my previous response is what you should be looking at.
The variable that you store the state of vip once you read that from the JSON document should be a boolean as it holds true or false values.
06-04-2023 12:26 AM
Below the screen short
and I created the string value "result[0].vip" to match the result.
Let me create the boolan variable and try it.
06-04-2023 01:16 AM - edited 06-04-2023 01:19 AM
From what I can see in your picture you are not doing the get JSON steps correctly.
You need to query the values that are in the result branch, see it like a path statement. For example for VIP you put this in “result.vip” verbatim, the path of this would be result and under it there is a value named vip that contains true. Then you store that in a variable that is of the type boolean. The variable type should be matched to fit the type of data of what you read from the JSON document.
06-04-2023 02:14 AM
I have created 2 string . Details below
1.
2
below variables are updated in the JSON properties.
below responses are coming from the results.
U"{\"result\":[{\"user_name\":\"11234567\",\"u_empgrade\":\"C2\",\"vip\":\"true\"}]}"
and I am not getting any response value
06-04-2023 04:49 AM
You don’t need the first variable, put the value from that directly in the JSON path in the get JSON document step and your second variable should be of the type Boolean. I have no idea if this would make any difference. You keep referring to the result from the REST lookup, have you put that into the JSON document and if so what is the content of it?
06-04-2023 06:33 AM - edited 06-04-2023 06:33 AM
Can you give a Rest look up scren shot.
06-04-2023 07:40 AM - edited 06-04-2023 08:01 AM
I took you result from the REST call and created this simple script to get the value that you have asked about.
There are a few things with your result from the REST call that makes it not work with what I suggested.
In my script that tried to attach, but I just get "Sorry, unable to complete the action you requested." I added two set steps that does this.
There are for sure cleaner ways to do this, but I’m not that great with the expression language and I’m for sure not a Java programmer. So I did it the simplest way.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide