Workflow transition trouble with rejecting non PDF files [SOLVED]

When things don't work as they should.
Post Reply
squir002
Posts: 2
Joined: Mon Jun 22, 2020 7:57 am

Workflow transition trouble with rejecting non PDF files [SOLVED]

Post by squir002 »

Hello!

I am trying to figure out what is wrong with my setup.
What I am trying to achieve:
1. I have set up a few sources that import files into Document type and I made a Workflow that is attached to this Document type.
2. Once a file is imported, it goes to the New state of that workflow.
3. On "Document version parsing finished" trigger, transition called "Reject non PDF files" is executed. I except file to be moved to 'Rejected' state when its FileType from EXIFTool is not 'PDF'.
4. Rest is going to be handled manually.

So I have a transition "Reject non PDF files":
Origin state: New (initial)
Destination state: Rejected
Condition:

Code: Select all

{% if workflow_instance.document.file_metadata_value_of.exiftool_FileType == 'PDF' %}None{% else %}Not a PDF file{% endif %}
If I understand things correctly, when the condition returns 'None' or an empty string, the transition will not be executed. So above example should return 'None' when the file is PDF and 'Not a PDF file' when it isn't. I have checked the condition in the sandbox and it works like expected. One important thing to note, I did test it in the sandbox without "workflow_instance." in front, while inside workflow transition, this part seems needed and I can't (don't know if possible) test it there.

So main problem is this condition always ending as true and even PDF files are being moved to the Rejected state.

What am I doing wrong? Could someone please put some light on this thing? I would be more than thankful for any help!

User avatar
franco
Developer
Developer
Posts: 29
Joined: Sun Apr 05, 2020 2:30 am

Re: Workflow transition trouble with rejecting non PDF files

Post by franco »

Hi,

The None value in the description refers to Python's logical None and not a string "None". While this might be obvious to people with Python background I can see how this explanation needs to be expanded.

Therefore the revised condition would be as follows:

Code: Select all

{% if workflow_instance.document.file_metadata_value_of.exiftool_FileType == 'PDF' %}{% else %}Not a PDF file{% endif %}
Or simply:

Code: Select all

{% if workflow_instance.document.file_metadata_value_of.exiftool_FileType != 'PDF' %}Not a PDF file{% endif %}
Give this a try.

squir002
Posts: 2
Joined: Mon Jun 22, 2020 7:57 am

Re: Workflow transition trouble with rejecting non PDF files

Post by squir002 »

This actually works! Thank you so much :)

Post Reply