cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to debug an iWorkflowscript in OnBase Studio?

Anthony_Valle
Star Contributor
Star Contributor

I have an iWorkflowScript that I would like to debug. Can I do that somehow without running a document through workflow? Or is there any tips on how to test it?

Thanks,

av

3 ACCEPTED ANSWERS

Eric_Beavers
Employee
Employee

I am not sure of how to test without a document.

I like using the app.diagnostics to write message to diagnostics console. Here are some examples:

app.Diagnostics.Write("keyword is: " + keyword.KeywordType.Name.ToString());
app.Diagnostics.Write("keywordVal is: " + keyword.Value.ToString()); 

app.Diagnostics.Write("Found Match!");

View answer in original post

Shane_Cook
Star Contributor
Star Contributor

Hi Anthony,

You can use a "System Task" to execute an IWorkflowScript. I find this technique useful because you can simply use retrieval to find a list of potential test documents and then activate the system task on the document(s) right from the retrieval window.  Note: The document type needs to be configured for the System Task and a workflow license is consumed during the execution of the system task processing.  See the Workflow MRG for more specific details.

View answer in original post

Alex_French
Elite Collaborator
Elite Collaborator

If you're licensed to use the API outside of Unity scripts-

If your scripts get complex, or if you just are spending a lot of time testing/debugging simple things, the next step after Eric's suggestion and Shane's suggestion may be to start writing scripts in a way that can be executed outside of the Unity Script.

Write all your business logic in a method(s) that accepts the inputs you need, and can be run *without modification* from Visual Studio or a lighter weight tool like VSCode or LINQPad. 

Only pass inputs that you can recreate outside of the Unity Script. Don't pass the args object- you can't easily create one for testing.  Pass things like the app object and the args.Document object.  If you query an external database using a Unity Connection String, pass the database connection into your method(s) so that you can create a comparable connection outside of the Unity Script.

You can also structure your overall business logic with this in mind.  Instead of having a Unity Script set Keywords, you might have the script calculate a value and set a property, which Workflow can use to set a Keyword.  Don't do this if it is just extra complexity, but it may let you build business logic ("calculate what this value should be for this document") that can be written *and executed* in an IDE quickly, instead of writing in Studio, build/publish/reset manual actions in a client to trigger Workflow / look at results.

In some cases this might even lead to automated testing outside of the Unity Script, but it can be very without ever expecting to automate testing.

Re-structuring code to execute outside of your Unity Script will add some complexity to the simplest things, and in some cases can be misleading (some things behave differently inside a Unity Script), but even very small debugging problems can often be much more pleasant with an IDE and debugger than with a build/publish/reset/execute/view diagnostics/guess/change/add more diagnostics/build/publish... cycle.

View answer in original post

5 REPLIES 5

Eric_Beavers
Employee
Employee

I am not sure of how to test without a document.

I like using the app.diagnostics to write message to diagnostics console. Here are some examples:

app.Diagnostics.Write("keyword is: " + keyword.KeywordType.Name.ToString());
app.Diagnostics.Write("keywordVal is: " + keyword.Value.ToString()); 

app.Diagnostics.Write("Found Match!");

Shane_Cook
Star Contributor
Star Contributor

Hi Anthony,

You can use a "System Task" to execute an IWorkflowScript. I find this technique useful because you can simply use retrieval to find a list of potential test documents and then activate the system task on the document(s) right from the retrieval window.  Note: The document type needs to be configured for the System Task and a workflow license is consumed during the execution of the system task processing.  See the Workflow MRG for more specific details.

This is a great tip. All the responses are useful but this is what I was looking for to debug the logic on a document in a quick manner. Thanks!

Tremendous tip for debugging, but remember to remove it before moving to production 🙂

Best,
C. Adam Kuhn, API Analyst
OCAPI | OCWE | OCWA | OCASA | OCI