Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Save integer or string to xml or text file

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
Green

Re: Save integer or string to xml or text file

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

Do you know your Java?

Regards,

Geoff

New Member

Re: Save integer or string to xml or text file

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

Green

Re: Save integer or string to xml or text file

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

335
Views
0
Helpful
3
Replies