I need to process an XML file that is being put into a windows folder (on the Workflow server). Is there an easy way with WF activities to read that Windows file or do I need to use the WF Script and load the file content to a token, and use that token in the Read XML activiry?
Question
Question
Workflow "Read XML" to process an XML file in a windows folder
Replies
The activity expects the XML to come from another activity, like a HTTP Web Request or Download Electronic Document.
If you really need to, you can also use a "Retrieve Document Text" and give the text token it produces to Read XML.
Hi,
Can anyone share a detailed workflow for this? I am getting this error. "29/05/2017 5:15:20 PM Download Electronic Document The source entry '01 Document Onboarding' is not a document [0287-WF0]"
How do I set this to download the XML from hot folder?
Best regards,
So your XML file is in the repository? And you find the XML file with the Find Entry activity?
That should work. Make sure that the Download Electronic Document is set to Download From the Find Entry Output.
Thanks for the quick reply Brent.
The xml file is located in the windows directory C:\. I also set the DED to download from output entry. I attached the error from the workflow.
If the XML file is not in Laserfiche, but rather in Windows, you must use a Script activity to read the content of the XML into a token. To start with create a token with the windows path for the XML file and name the token XMLWinPATH. Then use regular Script activity (not a SDK Script) to read the XMLWinPath token and load the XML content into a token called XMLContent. In your Read XML activity, point the source at the script_xmlcontent token.
Protected Overrides Sub Execute() 'Write your code here. Dim XMLContent As String = Nothing Dim ScriptError as String = Nothing Dim sWinPath as String = TokenReplace("%(XMLWinPath)") Dim fi as New System.IO.FileInfo(sWinPath) If fi.Exists Then If fi.Extension.ToLower() = ".xml" Then Try Using sr As New System.IO.StreamReader(sWinPath) XMLContent = sr.ReadToEnd() End Using Catch ex As Exception ScriptError = ex.Message End Try Else ScriptError = "File not XML: " & sWinPath End If Else ScriptError = "File not Found: " & sWinPath End If SetToken("ScriptError", ScriptError) SetToken("XMLContent", XMLContent) End Sub
Use a Track Tokens activity to read the XMLContent and/or the ScriptError tokens.
Thank you very much Bert, this works great.
I really appreciate your help.
Best regards.