I am not sure if this is possible. I know there is a way to disable or delete an event handler using Powershell. But is there a way to pause an event handler using Powershell? I have three event handlers that trigger on a sharepoint list I have. but I do not want to delete it I just want to pause it.
-
1Are you able to edit either the Script Editor, .html, .aspx, or .js file where the event handler is? If so you could just comment out the even handler's contents or declaration briefly. As far as I'm aware you can't do this with PowerShell.KGlasier– KGlasier2018-12-19 17:55:04 +00:00Commented Dec 19, 2018 at 17:55
-
@KGlasier Unfortunately I am not able to edit the script. Is there another way? ThanksSharePoint Lady– SharePoint Lady2018-12-19 22:27:11 +00:00Commented Dec 19, 2018 at 22:27
Add a comment
|
2 Answers
From your question is not clear why you want to "pause" the event receiver, but I will assume you are creating/editing list items from PowerShell.
In this case it is possible to prevent event firing:
$assembly = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $assembly.GetType("Microsoft.SharePoint.SPEventManager");
$prop = $type.GetProperty([string]"EventFiringDisabled",`
[System.Reflection.BindingFlags] `
([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Static));
#SET EVENT FIRING DISABLED.
$prop.SetValue($null, $true, $null);
<#
DO WHAT YOU NEED TO DO
#>
#SET EVENT FIRING ENABLED.
$prop.SetValue($null, $false, $null);
Script credits to Ivan Yankulov
-
I wanted to pause to ensure that I would be deleting the correct handler. The logic is that if it is the correct event handler I can delete or disable it. I am just not sure what is behind the event handler. ThanksSharePoint Lady– SharePoint Lady2018-12-19 22:29:00 +00:00Commented Dec 19, 2018 at 22:29