12-08-2022 05:27 PM
Hi Everyone. New cisco account, so it looks like I'm new here. But I've been around for about a decade now. Over the last couple of years, I've deep dove in to Python programming, and gotten pretty competent in it. I'm a Cisco voice engineer by trade. I've done plenty of basic uccx scripts over the years, and finally feel ready to go further.
I'm working on a on call rotation script. I have to say, the way that uccx parses data is pretty horrendous. It took me all day to figure out how to count the number of items in an array. I was trying to get things working with XML until I saw json is an option. I know json construction well, but have found it very difficult within the uccx editor.
I've gotten to the point that I can pull in a JSON, and count the number of items in the array (which will change over time of course). I have the script able to do all the math to determine the value it needs. I have that number set in an integer. But I cannot figure out how to use the integer as part of the json path.
"$.oncallList[0]"
The above is a proper location, where I could pull data. I need to use a variable where position 0 is on this path. I've tried
"$.oncallList[ (rotation_number) ]"
"$.oncallList[ int(rotation_number) ]"
"$.oncallList[rotation_number]"
None of those work. How do I use the rotation_number variable as the item number?
12-08-2022 06:11 PM
Solved my problem. Had to build my xpath as a string variable, and then use that variable inside the get json data.
Uccx scripting is totally lame.
12-08-2022 10:21 PM - edited 12-08-2022 10:22 PM
The get JSON steps needs the value to be a string, so if you’re using a variable it has to be in the form of a string. Once you get over the hump of initial difficulties CCX scripting is actually quite powerful. I give you that it is somewhat quirky and sometimes downright annoying, but it is not all that different from learning any other new developer tool.
03-22-2023 12:59 AM
screenshot or the detailed explanation will be appreciated. I have json as string and i need to get specific parameter value from it, I am stuck on this task. for 2 days now, started working on this 2 days back.
03-22-2023 01:19 AM - edited 03-22-2023 03:28 AM
Maybe this could help you?
03-22-2023 02:31 AM
thanks for quick response, can you explain how you converted response of string type to Document type .
I have response string which look like this, i get ot from 'Make rest call'
U "{\"count\":1,\"next\":null,\"previous\":null,\"results\":[{\"id\":1,\"url\":\"http://xx.xx.xx.xx:xxxx/api/circuits/providers/1/\",\"display\":\"it\",\"name\":\"it\",\"slug\":\"it\",\"account\":\"\",\"description\":\"\",\"comments\":\"\",\"asns\":[],\"tags\":[],\"custom_fields\":{},\"created\":\"2023-03-\",\"last_updated\":\"2023-03-20T12: \",\"circuit_count\":1}]}"
it contains 'U' at start and seems not valid json(uccx is converting it , checked with other tools like postman other service provide response with valid json), my requirement is to get the 'name' parameter from it which is inside the 'results' array.
Thanks in advance.
03-22-2023 03:07 AM - edited 03-22-2023 03:32 AM
The make JSON call stores the result and any other output from it in variables that are of the type string. Then the result variable is used to create the JSON document.
03-22-2023 08:45 AM
03-22-2023 08:47 AM
06-03-2023 11:26 AM
I checked your file and not able to see the Make REST Call. Once you created the Make Rest call go to properties and update details accordingly. Roger Kallberg already shared the information.
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