Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How can you verify an attachment exists?

Avatar

Level 2

On the leave request form that I'm working on, there are certain leave types that require that the form originator

attach some sort of documentation, like a doctor's note if they are claiming sick leave.

In my start point, I have the "Permit adding attachments" checkbox selected, and store the attachments in a process variable called "formAttachments", which is of type "document<list>".

In my processing, I need to verify that they attached a file. I have a decision point with a conditional route that is executed if an attachment is found in "formAttachments". I've run into a problem trying to find the proper way to make this determination.

I currrently have the expression:

get-collection-size(/process_data/formAttachments) != 0

I've also tried:

getDocAttribute(/process_data/formAttachments[1],"wsfilename") > ""

to check for the existence of a filename attribute. Neither of these works.

Could someone please help me figure out the proper way to check for the attachment?

Thanks much for any help.

2 Replies

Avatar

Level 2

Got it working. Should have used "get-collection-size(/process_data/formAttachments) > 0"

Avatar

Level 2

Upon further testing, I found that I had to create an integer variable called "numAttachments" and assign it the value of "get-collection-size(/process_data/formAttachments". I then check against the value of "numAttachments" in my conditional route. I'm assuming that get-collection-size does not evaluate as an integer, so you have to cast it to an integer value before you can use it.