PDF Region Condition in Workflow

Hello All

Due to a bug in Connect 2023.2 I have been advised to replace a text condition in my workflow with a Script Condition.

The text condition is looking for a string in a region and is true if found. This works in workflow but due to the “bug” it causes issues later on. I am having some issues with the VBS or JavaScript code to replicate what the workflow condition does.

Can anyone help with some sample code I can repurpose.

The bug is fixed in 2024.1 but I can’t wait that long.

Many Thanks

Can you post a screenshot of the Text Condition task as you would have configured it if it worked as expected? That will allow us to understand what kind of code you need.

Hi Phil

I have created a dummy workflow to illustrate.

Something like this should work:

var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(), false);

var extract = myPDF.pages(0).ExtractText2( 0.3125, 0, 2.8438, 0.4167 );
Script.ReturnValue = /#NOACREF#/ig.test(extract);

Drag a Run Script task onto your process and insert it as a condition:
image

Then copy and paste the code above in the task

1 Like

Many thanks for the swift response Phil.

Must admit I have not seen this type of code “ig.test” before, is it a Connect feature or just something I have missed?

Will give it a go when I can get on the server.

Thanks

John

No, it’s a Regular Expression. I admit my code is more concise than readable. To make it more obvious, I could have used:

var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(), false);
var myRegEx = new RegExp('#NOACREF#', 'ig');

var extract = myPDF.pages(0).ExtractText2( 0.3125, 0, 2.8438, 0.4167 );
Script.ReturnValue = myRegEx.test(extract);
1 Like