01-28-2019 08:27 AM - edited 03-14-2019 06:45 PM
I am trying to setup a script to call the primary or secondary on call listed in a SharePoint calendar. The SharePoint team has provided us with an XML export of the calendar. I am needing help on how to pull the primary and secondary number for the person on call for today. I don’t know how I would be able to look at the start and end time and only pull the primary and secondary contact information from the section for the current date. Any assistance would be appreciated.
<Department Name="Telecom">
<StartTime>2017-08-31 00:00:00</StartTime>
<EndTime>2017-08-31 23:59:00</EndTime>
<Description><div></div></Description>
<Notes></Notes>
<PrimaryContact Name="Doe, John">
<PrimaryContactBusinessPhone>123-456-7890</PrimaryContactBusinessPhone>
<PrimaryContactMobileNumber>123-567-8901</PrimaryContactMobileNumber>
<PrimaryContactHomePhone />
</PrimaryContact>
<SecondaryContact Name="Doe, Jane">
<SecondaryContactBusinessPhone>123-678-9012</SecondaryContactBusinessPhone>
<SecondaryContactMobileNumber>123-789-0123</SecondaryContactMobileNumber>
<SecondaryContactHomePhone />
</SecondaryContact>
</Department>
<Department Name="Windows Server">
<StartTime>2017-11-27 00:00:00</StartTime>
<EndTime>2017-12-03 23:59:00</EndTime>
<Description><div></div></Description>
<Notes></Notes>
<PrimaryContact Name="Doe, John">
<PrimaryContactBusinessPhone>123-456-7890</PrimaryContactBusinessPhone>
<PrimaryContactMobileNumber>123-567-8901</PrimaryContactMobileNumber>
<PrimaryContactHomePhone />
</PrimaryContact>
<SecondaryContact Name="Doe, Jane">
<SecondaryContactBusinessPhone>123-678-9012</SecondaryContactBusinessPhone>
<SecondaryContactMobileNumber>123-789-0123</SecondaryContactMobileNumber>
<SecondaryContactHomePhone />
</SecondaryContact>
</Department>
Solved! Go to Solution.
02-01-2019 11:37 AM
This image is a little busy, but it shows that the Xpather XPATH expression and the UCCX editor return the same value. Now, mine is slightly different than yours, so don't take it as the answer, but do use it as a guide. Did you also remove the time from the data as well? I don't see how the comparison of StartTime<='20190201' would work, with the time in there, so I assumed you removed it, and therefore, so did I.
01-28-2019 08:02 PM
01-29-2019 06:43 AM
Anthony,
1. We are going to be getting an automated daily export of the XML file. (that will overwirte the old version.)
2. There is a different person on call for each department. Some teams change who is on call every day others every week.
Thank you,
Anthony
01-29-2019 08:54 AM
Ok, let's build this thing up one step at a time.
First up, using the following website should be helpful in testing your XPATH expressions: http://xpather.com/
Second, using the following website should give you an idea of how XPATH works: https://www.w3schools.com/xml/xpath_syntax.asp
Third, in UCCX, you'll want to save the XML document in the Documents repository found under the Application menu. Probably in the default language folder, since this is likely not language specific.
Fourth, make sure the XML is valid when you save it, and right now, what you pasted is not. Maybe you pasted only a portion of it, so that's ok, but be sure it's valid XML first by using a site like: https://codebeautify.org/xmlvalidator
Fifth, use a Document variable in your script to reference the XML file in UCCX like this: DOC[myfilename.xml]
Sixth, use the Create XML Document step to convert the above file reference to an XML object, which is needed for the next step.
Seventh, use the Get XML Document Data step to read data from your above XML object, using an XPATH expression to describe what data you need from the XML Object, storing the output in a String variable. Even numbers are returned as Strings.
Eighth, validate that you got the output you needed, which could be a simple null check, or a length check.
Ninth, decide if a Call Redirect or Call Consult Transfer is more appropriate for your needs, to send the caller to the on call phone number.
Let me know which steps you have a handle on, and which you need help with.
01-29-2019 09:58 AM
I am needing help with formating the xpath. I am not sure how to get the contact number from the section that today's date falls in between (or on). Each department has several sections with different start and end times.
I am able to get this far. And using the xpather tool I am getting several results.
//OnCall/Department[@Name='Telecom']/PrimaryContact/PrimaryContactMobileNumber
01-30-2019 07:24 AM
I have progessed a little, but I am still unable to get only the oncall number for between the active dates.
//OnCall/Department[@Name='Telecom']['StartTime<=[%CurrentDateTime%]' and 'EndTime>=[%CurrentDateTime%]']/PrimaryContact/PrimaryContactMobileNumber
01-30-2019 03:44 PM
02-01-2019 11:09 AM
I removed all of the dashes from the xml file due to another site saying that xpath can't compare dates and suggesting to remove the dashes and compare that way. I am now able to pull the on call number for the needed dates on xpather, but when I try to pull the data in the script it is returning null.
xpath
//OnCall/Department[@Name='Telecom' and StartTime<= '20190201' and EndTime>='20190201']/PrimaryContact/PrimaryContactMobileNumber
02-01-2019 11:37 AM
This image is a little busy, but it shows that the Xpather XPATH expression and the UCCX editor return the same value. Now, mine is slightly different than yours, so don't take it as the answer, but do use it as a guide. Did you also remove the time from the data as well? I don't see how the comparison of StartTime<='20190201' would work, with the time in there, so I assumed you removed it, and therefore, so did I.
02-01-2019 11:55 AM
I didn't pull out the time and xpather was still pulling up the correct data. I just tried pulling out the time in the file the script is referencing and it worked. Thank you for your patience and help. Your solutions to other people's questions has helped me a ton in the past .
02-01-2019 02:01 PM
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