01-04-2021 11:36 AM
Hey everyone,
I am working on a CVP application that will return results from a SQL query and then send the returned row result(s) to an API. The query is working as expected returning the following XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <Results> <Row><SK_ID>5124</SK_ID></Row> <Row><SK_ID>5315</SK_ID></Row> </Results>
I am needing the results of each "SK_ID" entry to be fed into the following API:
<refURLs> <refURL>/unifiedconfig/config/agent/5124</refURL> <refURL>/unifiedconfig/config/agent/5135</refURL> </refURLs>
There may be varying results per query and won't be a set returned number every time. I have a local variable set to parse XML via XPath but not sure where to go from there. XPath is as follows:
importPackage(com.audium.server.cvpUtil); var xml = {Data.Element.Agent Skill Lookup.resultSet}; var ctr = {Data.Element.ctRows.count}; var path = "/Results/Row[" + ctr + "]/SK_ID"; XPathUtil.eval(xml , path);
Any help would be appreciated.
Chad
01-05-2021 08:45 AM
For anything like this, that's more complicated than simple logic, I like to make a custom Java node and put all of my data processing logic in that class.
So which part do you need help with: setting up the java class, the logic, or integrating?
01-05-2021 12:30 PM
Thank you for the response @Quigath. I am by no means a Java expert so would be hesitant in developing any custom classes (honestly have no clue where to start on that). From a support perspective if something were to break I would also not have the know how to support/troubleshoot it. If this would be the only solution I can certainly give it a go, however would not be my first option. Can you advise why this method would be the best? What does this class do that the built in elements could not?
01-05-2021 04:07 PM
I come from a Java/programming background so I suppose it's the first thing I think of. If there's any sort of data processing to do, it's much easier for me in plain java code rather than trying to get the gui and javascript to do the job instead.
From a software development perspective, having separate Java classes makes them easier to test and organize in source control too. The ones from Call Studio are harder to get a handle on.
Call Studio nodes are just specific Java class objects behind the scenes.
I tried to do almost exactly what you're trying to do: parse xml and send data to a webservice. I assumed that since it's what Call Studio provides that it must, somehow, be a better option. Usually, it isn't. Here I am several years later, still developing CS applications; now though, I assume that every project will be a mix of built-in and custom java nodes.
01-06-2021 11:20 AM
Unless there is a better way to do this I was able to get this working by the following call flow:
Here are the steps:
If anyone has a better way to do this I would be interested in learning. Note this is not the final call flow and will be tweaking to pass ICM variables for a more dymanic SQL query.
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