Programme rule to trigger if a file is uploaded

Hello DHIS2 community,

I would like to write a programme rule condition, so it triggers if a file is uploaded to a data element, and doesn’t trigger if it is left blank. Is this possible?

Jess

Hi @jschofieldwood

Welcome back to the community!

Then the program rule expression is going to be #{data_element_variable} != ''

This means that only when the data element has a value (the UID of the resource), it will trigger, but if it is left blank then it will not trigger.

Thank you!

I realised I actually need the opposite - I need the programme rule to trigger UNLESS there is a file uploaded.
I tried #{programme rule variable} == ‘’ , but it didn’t work. Do I need to put the UID of the DE in between the inverted commas?

1 Like

Okay, so the idea is that if no file is uploaded then it will trigger, so maybe:
!d2:hasValue(#{data_element_variable})

And if that doesn’t work, try:
d2:length(#{data_element_variable}) < 1

Please note that, if you copy/paste the quotation marks sometimes they don’t work so you’d need to type them rather than paste them.

Thanks!

Thank you! It worked!!

:slight_smile:

1 Like