How to bypass the Attach input sometime to be empty

I have an issue not every time I send email I want to attach the pdf but Its required to have attachment how can I bypass it to send email without attach


Screenshot 2024-09-10 at 13.31.52

I am trying to use attachPDFSwitch.value to set a null value when I don't want to attaching a PDF. However, it isn't working as expected. When the value is set to null, I'm encountering an error, as shown in the attached photo.

To resolve the issue of attaching a PDF, I added an empty array when PDF attachment isn't needed. This solution should be helpful for anyone encountering the same problem.
Screenshot 2024-09-10 at 13.45.41

2 Likes