JavaScript – Temporarily restricting access to a workflow

Applies to version 8.3.x; Author: Kamil Nędza

Sometimes it may become necessary to temporarily deny all users access to a workflow form.

This could be caused by the need to perform emergency maintenance during normal working hours. Removing access privileges from all users, and then returning them after the issue is solved, can be extremely time-consuming and tiresome for the admin.

Luckily, a simple JavaScript can be used to rescue us from this pickle. When a user tries gain access to the form on the SharePoint site, they will receive an alert informing them of the situation, and then be redirected to the main site.

alert(“Technical works. Estimated time 5:00-6:00 PM”);

window.location.href = “/default.aspx”;

This JavaScript should be entered in the Behavior tab of the workflow configuration – in the JavaScript to be executed on page load box:



We can enhance this JavaScript with an extra line to grant the specified user (warning – case sensitive) special privileges to access the form despite the restriction.

if (GetPairID(G_CURUSER) != „domain\\login”){
alert(“Emergency maintenance. Site will be unavailable between 5:00-6:00 PM”);

window.location.href = “/default.aspx”;}

This is very useful, as it will allow an admin/tester to monitor the form during maintenance.


When attempting to load the page, all unauthorized users will receive the message found in the JavaScript:


Clicking OK will redirect the user to the main page.


Once the issue is resolved, simply remove the JavaScript and save the process.

Leave a Reply

Your email address will not be published. Required fields are marked *