You are viewing limited content. For full access, please sign in.

Question

Question

Workflow "Read XML" to process an XML file in a windows folder

asked on August 21, 2014

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?

0 0

Replies

replied on August 21, 2014

The activity expects the XML to come from another activity, like a HTTP Web Request or Download Electronic Document.

0 0
replied on August 29, 2014

If you really need to, you can also use a "Retrieve Document Text" and give the text token it produces to Read XML.

0 0
replied on May 29, 2017

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,

Capture.JPG
Capture.JPG (24.7 KB)
0 0
replied on May 29, 2017

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.

0 0
replied on May 29, 2017

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.

 

Capture1.JPG
Captureerror.JPG
Capture1.JPG (26.9 KB)
Captureerror.JPG (40.33 KB)
0 0
replied on May 29, 2017

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.

0 0
replied on May 30, 2017 Show version history

Thank you very much Bert, this works great. 

I really appreciate your help.

 

Best regards.

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.