Workflow condition doesn't work with greater or equal to

I set a condition like this to one of the transition in my workflow:

{% if workflow_instance.document.metadata_value_of.invoicetotal >= 500 %}
True
{% else %}
False
{% endif %}

But it doesn’t work. I tried to test my condition in the sandbox and the result is always false although “invoicetotal” of the selected document is 600.

I make a guess that “document.metadata_value_of.invoicetotal” is a string so Mayan cannot compare it. So, I tried to put something like {% if **int(**document.metadata_value_of.invoicetotal) >= 500 %}, however, Mayan gives error when running it.

My full test in the sandbox as below:

{% if document.metadata_value_of.invoicetotal >= 500 %}
True
{% else %}
False
{% endif %}

{{ document.tags.all.count }}

{% if document.tags.all.count >= 1 %}
True
{% else %}
False
{% endif %}

{{ document.metadata_value_of.invoicetotal }}

And the result:

False

1

True

600

Please let me know if you guys have any ides how to resolve it. Thanks.

Yes, convert to number using any template tag that does numeric manipulation.

{% spaceless_plus %}
Average temperature: {{ document.metadata_value_of.temperature_average|abs }}
Average temperature: {{ document.metadata_value_of.temperature_average|div:1 }}
Average temperature: {{ document.metadata_value_of.temperature_average|mul:1 }}

{% if document.metadata_value_of.temperature_average|mul:1 > 70 %}
Result: Overheating
{% else %}
Result: Nominal
{% endif %}
{% endspaceless_plus %}

Result will be:

Average temperature: 92.5
Average temperature: 92.5
Average temperature: 92.5
Average temperature: 92.5
Result: Overheating
2 Likes

Hi Roberto,

The condition returns correct result after I used the template tag as you suggested. However, when I added that to the workflow transition’s condition, I’m not sure why it always show the 2 transition options while it should hide one of them (Total <= 500).

Do you have any idea?

My transitions:



And when running the workflow:

Looking forward to your reply.

Conditions that do not return any value, that return the Python logical None, or an empty string (‘’) are considered to be logical false, * any other value is considered to be the logical true *.

You template is returning a positive value on both conditions. Remove the {% else %}False part.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.