Action with condition not executed in workflow

Hi everyone,

I did quite a few cool things with workflows already but there is one thing that I did not get to work yet properly in my setup.

I have a state with an action (do OCR) that should only be executed when a certain transition was used to get to this state. So I added the following condition to the action:

{% if workflow_instance.get_last_log_entry.transition.label == ‘OCR wiederholen’ %}
TRUE
{% endif %}

However even when the corresponding condition was used the action is not executed. Since the expression relies on the workflow instance I am unable to use the sandbox to test where my problem is but maybe anyone has an idea what is going on?

Hi,

I’m not really sure if methods are usable in Django templates like get_last_log_entry() is.
Instead you could try last_log_entry which is the exposed returing value of the function.

{% if workflow_instance.last_log_entry.transition.label == "OCR wiederholen" %}
TRUE
{% endif %}

By the way: double quotes " are used for string comparison in Django templates as far as I have seen, I do not know if single quotes are also valid?

OMG that looks promising. No idea why I added the „get“. Thank you I will try that.

I also used double quotes before, this was just another desperate attempt :sweat_smile:

Unfortunately it did not work. And now I know where I got the template from: It’s provided in the use interface when you select last protocol entry from the model attributes dropdown. So I guess it should be correct. But thank you anyway for your support!

It could also be that I got the page condition wrong in the configuration of the OCR action. As far as I understand it it should return any value so that the page gets updated OCR information. So I just put the constant TRUE in there. But maybe I don’t really understand this correctly or the translation is bad :man_shrugging:

Actually it could also be that the action „Update document page OCR content“ does not do what I expect it to do at all… I’m a bit confused because of the last configuration option in the action that refers to a template for a document page to update the OCR content. I left this empty but probably this is why I do not see any results

Certainly you have already tried:
to get an idea if the condition expression is correct you could replace the OCR action to something you can see immediate results from, maybe adding a tag or comment Action to the document (just for testing purpose). If this works then you know that the expression is ok…

As simple as the idea may sound I actually did not try this yet so thank you for this suggestion. I will definitely try to do this.

The more I think about it the more I come to the conclusion that I was actually wrong about the usage of the OCR action. It appears that there exists no action type that lets you enqueue a document in the OCR pipeline. Maybe I can use the Rest API via a http action instead.