What I want to achieve: - users always forget to click the OK Button after reading a task - I want a message when someone closes the task tab like 'You closed this tab without closing the task. To close your task go to the ... and click the 'OK'-Button underneath the task description.

At first I tried the code at List -> form web parts -> default new form -> add web part: script editor

<body onunload="stop()"> 
<script type="text/javascript" language="JavaScript"> <!-- function stop() {   alert("Message from ...: You closed this tab without closing the task. To close your task go ... click the 'OK'-Button underneath the task description."); } //
    --> </script>

and this worked. Now I want the same to happen with my task form. I use the default sharepoint form (no InfoPath, no nintex forms).

Any ideas where I can type in the code? Thanks!

  • Thank you so much! It works :) – Sun Jun 15 '20 at 21:12

You need to open the form in edit mode. Then you can add a webpart. This is the url part you need to add to the url of your form: ?ControlMode=Edit&DisplayMode=Design

-> Complete example: (on my environment) http://site_url/subsite/Lists/listName/NewForm.aspx?ControlMode=Edit&DisplayMode=Design

-> another example: http://site_url/subsite/Lists/listName/DispForm.aspx?ID=1&ControlMode=Edit&DisplayMode=Design

Hope this helps

  • Most old SharePoint 2003 parameters also work: abstractspaces.wordpress.com/2008/05/05/… – Danny '365CSI' Engelman Feb 20 '17 at 14:16
  • I think you got my question wrong. I know how to add web parts to my New/Display/Edit forms, I want to add code to my task forms. Or can I type in the link to the library where the taskform is in? ... – Kim Feb 20 '17 at 16:21
  • Ok, I think I understand your question now. You have another form specific to tasks. It's not on any of my sites so I can't really help. Maybe SharePoint designer or add a custom action with a javascript link that loads on every page (with a bit of logic to detect when it is a taskform). Could also be its in the layouts folder. – Chris DS Mar 8 '17 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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