cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
587
Views
0
Helpful
3
Replies

Save integer or string to xml or text file

anthoney_murphy
Level 1
Level 1

I would like to save the date stored in a variable to an xml or txt file and cannot figure out how to do it. Any assistance will be appreciate.

3 Replies 3

geoff
Level 10
Level 10

Is this for UCCX or UCCE? If the latter, is this using IPIVR or CVP?

Do you know your Java?

Regards,

Geoff

UCCX and no not at all(Java). I am a quick learner though!!

That's cool.

One problem with writing to a file is concurrency. What happens if two calls come in at exactly the same time and execute the Java code at the same time, trying to open a file that the other already has open? Nasty business.

You would be better off writing to a database which has protection for concurrency.

That said ... there's probably a lot of ways to skin this particular pussy ... so here's one.

1. Declare an int variable to hold the return value of a Java snippet. It's not really useful, but we need it to make the expression editor work.

2. Add a Set step.

3. Right click Properties

4. Set the variable to the one you just created using the drop down list. It's an integer so our Java snippet will return an integer - in fact, the value 1.

5. click on the little ... to open the expression editor

6. put the Editor into Java mode

7. Insert something like this (don't forget the start and end curly braces)

{

java.io.FileWriter fw = null;

String fileName = "C:\\temp\\foo.txt";

try

{

fw = new java.io.FileWriter(fileName, true);

fw.write("something");

fw.close();

}

catch (java.io.IOException ex)

{

}

return 1;

}

8. Hit OK in the Expression Editor

9. Hit OK in the Set step.

10. Give it a shot.

Regards,

Geoff

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: