How can I create a program rule to know when a dataelemen of filetype has a file

I want to create a new program rule related to a dataelement of file type, I want to know when this dataelement has a file, I tried with d2:hasValue({ #programrulevariable }) function, but it doesn’t work, I tried with { #programrulevariable } == '' but it doesn’t work either, so, How can I evaluate if a filetype dataelement has a value?

Thank you very much for your answers.

Hi @dpperalta

Welcome to the community! I’m able to reproduce this issue and I think it’s a bug issue (or a feature request), so I will need to follow up with @tracker-programRules. Would you like to create a jira bug issue through your account in Projects - Jira?

After that please share the link here so other can add comments and follow for notifications.

Thanks!

Hi @dpperalta,

d2:hasValue(#{programrulevariable}) works for me - looks like you just put the # on the wrong side of the curly brackets.

Hi @superskip

I’m able to reproduce the issue even when using the correct program rule expression, the action is not triggered. Here are some screenshots:



image

I’m working on 40.0.3 https://play.dhis2.org/40.3.0/dhis-web-capture/index.html#/new?orgUnitId=duGLGssecoD&programId=IpHINAT79UW

I also tried the other day another expression VariableNameFortheFileResourceDataelement == ''

Ah, sorry! I did the test in Capture, but I see there are some problems with this in Tracker Capture. What I get is that the program rule doesn’t trigger immediately after uploading the file, but after refreshing the browser it does. Another error I’m encountering is that I get a server error when I try to delete an uploaded file. Same with you @Gassim, @dpperalta?

1 Like

I found an issue for the delete file error: [DHIS2-9586] - Jira

1 Like

Hi @superskip

Looks like I was testing in version 40.3.0 but in the Login app | DHIS2 instance, it looks like the program rule is working. :+1:

@dpperalta, thanks for working on this, if you check on the latest version, the program rule works in the Capture app.
image

@superskip, the deleting file issue you shared is different. In the Tracker Capture app, for deleting the file, the issue is in the enrollment page where the file has not yet been uploaded so if the delete button is clicked, the icon changes from delete to upload although the name of the file still appears in the field, if the upload file icon is clicked again, the file is replaced - so it’s only the fact that the name of the file remains in the field after clicking on delete.

1 Like