I have created a SharePoint list that automatically sends an email upon submission of a list item. One of the features I've added is a flag indicator '[*]' at the beginning of the email subject line when an item contains an attachment.

Because of some lack in mobile functionality, I wasn't able to use a condition of "if the list item contains an attachment, use this email template with the indicator, else use this email template that doesn't have a flag in the subject line" because attachments added via mobile were not detected for some odd reason, even though they were able to be viewed in SharePoint after submission (worked for Desktop, unfortunately not for mobile).

In order to get around this, I made it so if ANY of the drop down options contained a particular value (in this case the value is "Attached" to indicate that the requested information is attached to the list item), the email template with the flag indicator is used.

One issue I have considered is if a user selects a value of "Attached" on the list item, there is nothing forcing them to actually attach anything.

Is it possible to require/remind the user to add an attachment based on the condition that a drop down value equals "Attached"?

1 Answer 1


You can add this code to your NewForm.aspx and EditForm.aspx to check the attachment table rows - this requires an attachment all the time - you can add in the code to only check it whenever a certain choice is selected. I added code to show you how to grab a select value - if you use Jquery you'd need to reference where you'd actually get it from - I downloaded it locally to a library called Javascript with a folder called JQuery.

<script type="text/javascript" src="/Javascript/JQuery/jQueryMin-1.11.1.js"></script>
<script type="text/javascript" language="javascript">
        function PreSaveAction() {
            if($('select[title="FieldName"]').val() == 'Attached' {
                var elm = document.getElementById("idAttachmentsTable");
                if (elm == null || elm.rows.length == 0) {

                     alert("Please attach Documents");
                     return false ;
                } else { return true ;}
            } else {return true;}

To get the value of a dropdown, you could do something like this (this uses JQuery).


It's harder to do without JQuery since the id to use is very long, but you could use F12 to look at your dropdown to see what attributes are available.

  • Thank you for this. This is definitely outside of my experience level, as I'm fairly new to doing any SharePoint work. Can I add this anywhere, or does it need to be added to the already existing <script> block? EDIT: Also, would it be possible to provide an example of what a column title might look like in JS? I will be able to write the conditional statement, I'm just not sure what the columns would be titled.
    – Jake H.
    Jun 7, 2017 at 17:39
  • I usually put this kind of thing in a script editor since that's simple - just add a web part to the page (you can get to it from the list tab of the ribbon). I'll update my answer to show what a drop down select would look like. Jun 7, 2017 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.