Rushikesh
Rushikesh

Reputation: 529

How to make list attachment mandatory in SharePoint 2007

Anyone knows how to make attachment compulsory to the SharePoint custom list? We are using SharePoint 2007.

Upvotes: 0

Views: 3605

Answers (3)

Schmalzy
Schmalzy

Reputation: 17324

Add the below function as a script in a "Content Editor Web Part" or directly to the form via SharePoint designer. Obviously, this also requires jQuery.

function PreSaveAction(){ 

    var hasAttachment = false;

    //There are more then one fileupload inputs on the form
    //and one of them will always be blank
    $("input[name^='fileupload']").each(function() {
        if ($(this).val() != "") {
            hasAttachment = true;
        }
    });

    if (hasAttachment){
        return true; //OK to save
    }else{
        alert('An attachment is required!');
        return false; //Prevents user from saving
    }
}

Upvotes: 0

Gaurav Khurana
Gaurav Khurana

Reputation: 1

Better Create a workflow

which will send a mail to last modified by + cc team lead

"if the current item has attachment = no" send mail

Upvotes: -1

Paul Leigh
Paul Leigh

Reputation: 1231

There's nothing in the UI / Admin to do this AFAIK.

This arcticle explains how to achieve it with jQuery Link

Edited to correct my previous answer, which on reflection only provided a part answer. The above link is the correct way to achieve this. It shows the mechanism to query the attachments details on the NewForm, ie: before the list item is created, which is the point at which the mandatory function can be applied.

Upvotes: 1

Related Questions