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

Question

Question

Script is running successfully when tested in the Workflow Designer's Script Editor, but is failing when it runs as part of a workflow

asked on September 30, 2014

My script is running successfully when tested in the Workflow Designer's Script Editor, but is failing when it runs as part of a workflow. I am trying to read a file as below in the script editor. 

 long length = 0;
 var path = Path.GetFullPath(@"C:\Users\test.pdf");
 FileStream fileStream = File.OpenRead(path);
 length = (fileStream.Length);
  SetTokenValue("Length",path);

 

2 0

Replies

replied on October 1, 2014

You may be running the workflow as a different user than when in workflow designer. This would be the windows account, not the laserfiche account that doesn't have rights to wherever the filepath is in windows directory. 

 

That is at least the first thing I would check when getting an error like that.

1 0
replied on October 1, 2014

The scripts run as the connection profile user, not the user logged into Windows.

0 0
replied on August 11, 2015

How do you link a Laserfiche connection profile to the file system?

I am having a similar issue. I have a VBScript that is being called from within a Script and when using the Editor "play" button it works flawlessly, however, when its part of the Workflow it does not run.

The only code the script runs is:

System.Diagnostics.Process.Start("C:\\Powershell\\Createuser.vbs");

I have tested to make sure my VBScript is performing as it should as well. The problem seems to be a connection between the actual workflow running and the file. I also have talked to my Reseller.

1 0
replied on August 11, 2015

That's not possible. Why not put the script in the script activity in Workflow?

0 0
replied on August 12, 2015

The VB Script runs a Powershell that does a whole bunch of stuff. When I put the Powershell command in the Script utility, it errors. Even if I include the direct path to powershell.exe it errors. However, if I run it in a VBScript, it works just fine. That's why I was trying to just use the script utility to call a VBScript.

replied on August 12, 2015 Show version history

I am still unable to run a ps1 (powershell) file from my Workflow. Works fine when I press the play button but does not perform the tasks when part of the flow.

At least I eliminated the "System cannot find file.." error that I had at the beginning.

Code:

 protected override void Execute()
        {
            System.Diagnostics.Process.Start("C:\\Powershell\\create_ad_CardServices_users.ps1");

        }

1 0
replied on August 12, 2015

I meant putting your commands in the Workflow script. Is this PowerShell script creating a window when you run it? That won't work on the server since there is no user session.

1 0
replied on August 12, 2015

Yes, it creates a window that runs the powershell commands. I see what you mean now. I was curious if that should matter with the Workflow services having a Windows login in services.msc.

So the solution is to code Powershell commands into C#/VB by including the references,classes,etc?

0 0
replied on August 12, 2015

Right. I don't know what your script does, but you would want to put it all in script. Another way to go with be to have an executable that you could call with parameters.
 

1 0
replied on August 12, 2015 Show version history

Well in theory, I am running an executable (powershell.exe) with the argument -file. Workflow script isn't digging that either. Same result with the full path of the exe.

It runs just fine when I run it in the editor but won't fire off when the Workflow actually runs.

I wanted to avoid scripting the powershell commands in C#/VB until the end of time (there's a bunch of stuff that happens). Any other ideas?

0 0
replied on August 12, 2015

When scripting the powershell commands in and running the workflow, it did perform the steps as desired. I guess scripting it is! :)

2 0
replied on September 30, 2014

What is the error? Are you trying to find the size of the PDF file?

0 0
replied on October 1, 2014

The error is "Cannot find part of the file". Yes, I am trying to read the file and find the length. Is it because my workflow designer is in a different machine than the wokflow server? Should I put the pdf in the same location in the wokflow server too?

0 0
replied on October 1, 2014

In the context of testing your code in the Designer on your computer, that value "C:\users\test.pdf" is using your local machine. I think we should take a step back and ask what the purpose of your script is. If the purpose is to find out the size of a PDF document in your repository, there are more direct methods than writing the pdf to disk and finding the size through .net. As it stands, your sample is putting "C:\users\test.pdf" into the token "Length," which also does not seem to be what you want.

0 0
replied on October 10, 2014

Thanks. How do you read a pdf file from the repository in the workflow script?

0 0
replied on October 10, 2014

I dont want to put the pdf file in the workflow server. The script should be able to pull from repository.

0 0
replied on November 7, 2014

How do I read a pdf file from repository please? Please give some sample code in C#. Thanks.

0 0
replied on March 5, 2022 Show version history

It's 2022, and we still come across this problem "Script is running successfully when tested in the Workflow Designer's Script Editor, but is failing when it runs as part of a workflow"

The issue occurred when we tried to read files on server like;

FileStream fileStream = "C:\\Temp\\test.pdf"
 

It seems running the script directly in Workflow designer(running directly on server) is ok, but we could not obtain the same result when running workflow in the Forms process(which triggered from a client).

Does anyone have a solution ?

0 0
replied on March 7, 2022

Are you getting an error? Does the WF Server's service user have read access to the location where your file is stored?

0 0
replied on March 8, 2022

After looking at the log. It turned out the issue caused by something else, not the permission.

Fortunately, Workflow Admin Console >> Monitoring >> Error log has enough information to debug the issue (My script sometimes stop working since Form passed Float/NULL to INT variable)

 

In conclusion, my case was resolved.

1 0
replied on February 17, 2023

I was able to fix mine by making it  destination folder a UNC path and also making my wfservice account Admin

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

Sign in to reply to this post.