Expand my Community achievements bar.

Passing parameters to a workbench process invoked by watched folders

Avatar

Former Community Member
I am trying to pass values to a workbench process that is invoked by watched folders. What I need to be able to do is at least provide a path (string) to the process so that it knows where to store one of the result files. This value is not always the same and for reasons that I don't want to get into, I don't want to use an "output" variable to send it to the watched folder's "result" folder.



So, I had the idea of saving the value in a text file with a standard name (same for each call to the process) and my process would look for this file and import the file contents into a string variable. I wasn't able to do this.



#1 I haven't found a way to store the file content of an existing document variable into a string variable. Is this possible?



#2 I tried using the "Read String" service to read the contents from the file and store them into a string variable. Should be pretty straight forward, right? Turns out the process would just hang when trying to read the file into a string. I then tried changing the output variable from type 'string' to type 'document' and whammo, it worked. The variable logger showed the correct file contents. So it appears that "Read String" and "Read Document" do the exact same thing; read a file into a *document* variable! So now I'm stuck with issue #1 again...



Any suggestions? I have version 8.0.1 of LiveCycle installed.
7 Replies

Avatar

Former Community Member
I found the problem. The "Read String" activity's output variable must be of type "binary", not "string".



This is actually quite ironic:

- The activity is called "Read String", emphasis on *string*, but the output variable can't be a of type "string".

- The process works with a variable of type "binary", but if you try to load a binary file (ie, a PDF) the result is corrupted with a bunch of '?' characters (or is that just the logger that's corrupting it?).

Avatar

Former Community Member
OK, so my previous solution does not work very well. Converting from 'binary' to 'string' does not seem to be easy. Assigning the binary variable to a string variable results in gibberish, even with the string() function. The good news is I found a better solution:

- Save your parameters as an XML document.
- In your Read String activity, use a 'xml' type variable as the output.

So, take this basic XML code for an example:


Coke

Cheese
mushrooms



If you save this to your watched folder and read into an 'xml' variable named 'myXml' using the Read String activity, you'll be able to do the following (assuming myString is a 'string' variable)

/process_data/@myString = /process_data/myXml/drink
/process_data/@myString = /process_data/myXml/pizza/top1
(etc.)

Avatar

Level 10
Let's take a step back here.



The Read String activity will read the content of a file that contains strings into a STRING variable. In fact you need to provide a variable of type string for the output results.



I think the problem is that your trying to read XML content which is not treated as a string by LiveCycle.



If you want to read XML content then use the Read Document activity. It'll put the content of the XML in a document variable. Then you can use a SetValue and put the content of the document variable into a XML variable and use xPath to get to the value you need.



/process_data/myXML = /process_data/myDocument



You have to use a XML variable if you want to use xPath. xPath won't work on a string variable since the string content doesn't really have structure. You need a XML variable which gives you the structure.



If you really want to, you can convert the XML into a string (using the serialize xPath function) and have the XML treated as a string but I don't think that's what you're trying to do.



Jasmin

Avatar

Former Community Member
If I use a 'string' variable with the Read String activity, the process stalls with this error:



Data truncation: Data too long for column 'doccontent' at row 1; CausedByException is:

Data truncation: Data too long for column 'doccontent' at row 1



I tried this with a brand new, basic process that had only two activities: the Read String and a logger.



I only used an 'xml' variable when I couldn't get it to work with a 'string' variable.



The content of the file I was trying to read directly into a variable contained only one line of text (a path). I now changed this to an XML document and it works...

Avatar

Level 10
"Data truncation: Data too long for column 'doccontent' at row 1; CausedByException is: "



Make sure the length of your sting variable is big enough to hold the path information. You can change it under properties.



Jasmin

Avatar

Former Community Member
I left the length field blank. The source file was like ~50 bytes.

Avatar

Level 10
Then put a length that will hold 50 bytes of data. Just put 1000 or something.



Jasmin