Make asynchronous event handler as synchronous using Powershell

Hi All,

Using custom coding i am able to change the asynchronous event handle to synchronous.

Can anybody let me know Is there any other way to change the same. Like Powershell script or any.

Without deploying the solution i want to change the event handler type.

Please advice.

Thanks & R

April 27th, 2015 2:48pm

  

Hi 
you can use power shell to do so

Add-PSSnapin Microsoft.SharePoint.PowerShell erroraction SilentlyContinue 
$web = Get-SPWeb -Identity http://...
$list = $web.GetList($web.Url + "/Lists/" + list name) 
$type = "ItemAdded" #or any other type, like ItemDeleting, ItemAdding, ItemUpdating, ... 
$numberOfEventReceivers = $list.EventReceivers.Count 
if ($numberOfEventReceivers -gt 0)
{
 for( $index = $numberOfEventReceivers -1; $index -gt -1; $index-) {
    $receiver = $list.EventReceivers[$index] ;
    $name = $receiver.Name
    $typ = $receiver.Type ;

 if ($typ -eq $type)  #or you can check ($name -eq "event receiver's name") if you have more then one event receivers of the same type
 {
    $receiver.Synchronization = "Synchronous"
    $receiver.Update()
    Write-Host "Event receiver " $name " is changed to Synchronous"
 }
 }
}
else
{
    Write-Host " There is no EventReceiver of type " $type " registered for this list "
}

$web.Dispose()
or
$list = (get-spweb http://sharepoint/sites/test).lists['somelist']
$def = $list.EventReceivers.Add()
$def.Assembly = "MyReceiverAssembly, Version=1.0.0.0, Culture=Neutral,PublicKeyToken=a00000000a000ce0"
$def.Class = "MyReceiverAssembly.MyReceiverClass"
$def.Type = [Microsoft.SharePoint.SPEventReceiverType]::ItemAdded
$def.Name = "My ItemAdded Event Receiver";
$def.Synchronization = [Microsoft.SharePoint.SPEventReceiverSynchronization]::Synchronous
$def.Update()


this should be done at each level where list is present.

or you can Edit the Elements.xml file of the event receiver in(14 hive layouts/feature folder) and set the synchronization element as below..

<Synchronization>Synchronous</Synchronization>

Synchronous</Synchronization> https://naimmurati.wordpress.com/2012/03/22/add-modify-or-delete-list-event-receivers-with-powershell/">https://naimmurati.wordpress.com/2012/03/22/add-modify-or-delete-list-event-receivers-with-powershell/

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 3:50pm

Hi Rajendra Pratap,

Thank you for the script.

Using the PowerShell script i am able to change the event type. But i would like to know how can we check if 'ItemUpdatd' event receiver changed to Synchronus.

I used below script to check the event receiver typs. But it is still showing 'Asynchronous'

$list.EventReceivers | Select Assembly, Synchronization | format-list

Thanks & Regards

May 18th, 2015 11:08am

Hi

try to deactivate and activate feature.

You can use share point manager to check so,and you can also change the same using share point manager.

https://spm.codeplex.com/

Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2015 12:55pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics