SharePoint PreSaveAction helps for actions before saving an item

If you’re customizing SharePoint listforms or SharePoint forms you have normally a save or cancel button. If you want to have a pre-action for the save button, that means there should something happen before the item will be saved if the user clicks on the save button, you can use the javascript function PreSaveAction(). This function takes place before saving the item.

I my customer project i need this function for the following scenario. The user has to choose a value from dropdown list. If the selected item from dropdown has a special value, the user should get a message, that informs him about a special situation and that he should confirm to proceed.

[sourcecode language=”csharp”]

[/sourcecode]

After that the message appears if you click the save button:

jsScript

Hope this helps you.

I already posted about SharePoint forms or Listforms. Let me give you the links to my previous posts:

Part 1: Setting up a solution with a list definition, a list instance and deploy it.

Part 2: Creating a custom list form and connect it with the list definition.

Part 3: Necessary settings for custom listform in Visual Studio

Part 4: Override Save Button in listform

Part 5: How i can make attachments working in listforms

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

1 Comment

1 Trackback / Pingback

  1. Validate a column only on edit | CL-UAT

Leave a Reply

Your email address will not be published.


*