cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1183
Views
5
Helpful
3
Replies

UCCX Create File document text

MikeHoliday
Level 1
Level 1

I have the following script. In the document (txt) I write a record which I record. If I want to delete it, then I write "blank" in this document.

How would you then read this document in order to determine if it was blank in the document or is it in the record document?

3 Replies 3

Jonathan Schulenberg
Hall of Fame
Hall of Fame
Are you referring to a Document-type variable with a TEXT[] value; or, a text file you are reading from the Document Repository?

If the former, a simple If myVariable.length() == 0 would do it. Be careful to catch NullPointerException though. Nested if logic can do that:
if myVariable = null {
return false;
} else if myVariable.length() == 0
return false;
} else {
return true;
}

It's a .txt file that I read from document repository 

Using the Set step to "read" a document, will put that documents contents in your variable.

 

Example:

 

Read a file from the Document Repository

Set file_contents = DOC[myfilename.txt]

BONUS: Read a file from the web

Set file_contents = URL[http://servername/myfilename.txt]

In each case, you would then just work with the variable as a normal variable, checking for null, empty, or specific content.

/* Check for null or empty */
If (file_contents == null || file_contents.trim() == "")
  True
    /* File has no content */
Goto Default Path False If (file_contents == "banana")
True
/* Anthony was here */

As @Jonathan Schulenberg  said, watch out for situations where you are trying to read a file which does not exist; your script will abort unless you catch the Exception

 

If you're new or just plain curious about Exceptions, you might find my article on discovering exceptions helpful: https://community.cisco.com/t5/collaboration-voice-and-video/uccx-discovering-exceptions/ta-p/3124590

 

Good luck, and let us know how it goes.