Welcome to an article on ‘Pre-Save Action on Document Libraries in SharePoint 2013 and Office 365.’ We developers face an issue when our client wants to have an action done on a document library on a save click.
Document Library uploads the document, and to validate something on the save click is tricky as the save by passes the validation and gets saved.
- Open your Document Library
- Under the ‘Library’tab , click on the Form Web Parts.
- Choose Default Edit Form, you will see the screen below.
- Click on Add a Web Part,
- Choose Script Editor, under the Media and Content Web part.
- Click on Edit Snippet, you will see the screen below.
- Use the code below and click Ok.
- function PreSaveAction()
a. Use the function PreSaveAction() and paste your validation under the function on the code.
b. Before saving document library the code will check your validation and will get saved.