08-29-2019 12:19 PM
Hello,
I am currently trying to get a script setup for On Call purposes. I am not versed in Java and am having a hard time getting the Java end of the script working. Currently I have an XML file I am working with, below is a sample of it:
<Worksheet ss:Name="Schedule">
<Table ss:ExpandedColumnCount="34" ss:ExpandedRowCount="18" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="15.75">
<Column ss:Width="108.75"/>
<Column ss:Width="145.5"/>
<Column ss:AutoFitWidth="0" ss:Width="94.5" ss:Span="31"/>
<Row>
<Cell ss:StyleID="s16"><Data ss:Type="String"></Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">Position</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">Total: Paid hours</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">Wed, May 1</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s16"><Data ss:Type="String">Jane Doe</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">Service Desk On Call</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="Number">126</Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String">On Call</Data></Cell>
</Row>
The bold text are fields I am currently trying to work with. I've already got the date formatted correctly in the script I just need help on how to write the following items using Java:
1. Searching the XML file for the matching date. ex: If today is Wed, May 1 find what row/cell Wed, May 1 is in.
2. Checking the corresponding cell in each row for "On Call" ex: Wed, May 1 is in Row 1, cell 4 so check the 4th cell in each row.
3. If they are "On Call" checking the second cell in that row for if they are on the "Service Desk"
4 If they are on the "Service Desk" checking the first cell in that row for their name: ex "Jane Doe"
Any help on this topic would be greatly appreciated.
08-29-2019 02:37 PM
That XML file looks crazily complex compared to most XML files commonly used with UCCX.
How was it generated and do you have to use that format?
08-30-2019 06:00 AM
08-31-2019 12:57 PM
I am wondering whether it would be better to try integrating with MS Shifts using the REST based API rather than trying to parse an exported XML file?
The Shifts API seems very new and is documented at the link below.
https://docs.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-beta&tabs=http
08-30-2019 06:42 AM
Hi - first of all your xml isn't complete, you're missing the closing </Table> and </Worksheet> tags.
I don't know UCCX, but I do know XPath parsing.
Your data better always be coming back with the same number of rows in the same order, else I don't see any way to know where the data of interest is.
Anyway, these are the XPath expressions for the first 2 bolded items you asked about.
Wed, May 1 is: /Worksheet/Table/Row[1]/Cell[4]/Data
Jane Doe is : /Worksheet/Table/Row[2]/Cell[1]/Data
Note that in Notepad++ you can use the Plugin Manager and install XML Tools.
There you can go to Plugins > XML Tools > evaluate the xpath expression and test things out, very useful!
Are you going to be coding this in Java? Or JavaScript? Maybe I could help.
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