04-18-2018 10:28 AM - edited 03-14-2019 06:07 PM
I am trying to create a script that will allow my user base to set emergency weather closures based on location. This particular customer has six locations which I am trying to manage on one XML. I keep running in to errors with the XML upload and I'm not quite sure where I have gone wrong. I would appreciate any input the community has to offer.
Everything validates fine. The prompts are uploading appropriately. I feel like I am doing something wrong with the formatting.
04-18-2018 11:25 AM - edited 04-18-2018 11:57 AM
That's interesting, I have never seen anyone use XSL files in UCCX scripting. Could you explain how it works?
I'd wager most people just use the Keyword Transform Document step, which uses a very simple find/replace model to change documents. However, this requires you to either split up the states into separate files, or to juggle all of the data each time you read/write to the file (probably something the XSL handles well, but I don't know anyone who has got that to work).
E.g.,
Template File
<?xml version="1.0" encoding="utf-8"?> <SevereWeather> <FlagState_AL>%FlagState_AL%</FlagState_AL> <FlagState_GA>%FlagState_GA%</FlagState_GA> </SevereWeather>
Pseudo Script
Set xml = doc[weather.xml] Set template = doc[weather-template.xml] Create XML Document (xml) /* Read status of all states */ al_status = Get XML Document Data (xml, "//FlagState_AL") ga_status =Get XML Document Data (xml, "//FlagState_GA") /* Inform caller of current status for chosen state */ /* Get new status from caller for chosen state */ Set al_status = "emergency" /* Update all statuses using keyword transform */ xml = Keyword Transform Document (template) /* Change file in repo */ Upload Document (xml to l[], "weather.xml")
You might find it easier to avoid XML all together, and just have different files for the different locations, and have the contents be plain text.
E.g.,
File
state-of-al.txt
Content
normal
Pseudo Script
/* Use a menu to get state choice */ Set target = "al" /* Construct the filename for target state */ Set filename = "state-of-" + target + ".txt" /* Get current status of target state, and inform caller */ Set current_status = doc[filename] /* Use a menu to get new state choice */ Set new_status = "emergency" /* Change the document in the repo */ Upload Document (text[new_status] to l[], filename)
04-19-2018 01:06 PM - edited 04-19-2018 01:08 PM
Anthony,
I have implemented the steps from the pseudocode, but the transformation step seems to be not working properly. Please see the attachment. Am I declaring a variable improperly?
the var_flagAL, etc just have "normal" as their values. You can see that the script is reading the XML and the XML templates properly.
04-19-2018 03:53 AM
Hi,
A better solution might be to achieve this from an easy-to-use web administration portal instead of doing complex and lengthy scripting. We have a solution to this here: http://www.expertflow.com/announcements/
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