Add Event Receiver on Existing List in SandBoxed Solution
Hi Guys,
I have Created One Event Receiver which is of type SandBox Solution and now i am programatically adding Event Receiver to a Specific List Instance Which is Existing on Site.But
SPEventReceiverDefinitionCollection.Add() method is NOT available for Sandbox
solutions. Any Help would be Appreciated.
Thanks,
Nisarg S More
Christoffer,
And that's really straight-forward using the same method. Just change the Receivers element to target the specific list rather than the list template. Example:
<Receivers ListUrl="Lists/Test">
This works fine for me. Let me know if it doesn't work.
Thanks,
Dallas
Similar Messages
-
Attaching remote event receiver to a list on host web.
We have an O365 Sharepoint 2013 site. I am trying to create a remote event receiver and attach it to a list on host web instead of appweb. Below are the links that I am referencing to do it:
http://www.codeproject.com/Articles/636058/Adventures-with-SharePoint-2013-Remote-Event-Recei
http://blogs.msdn.com/b/knewton/archive/2012/12/11/defining-content-in-host-web-from-an-app-for-sharepoint.aspx
They are using 'AppInstalled' event to accomplish this. The method is as follows: get the client context of the host web, get our target list in the host web, get the service url of the remote event receiver using code below:
string remoteUrl = string.Format("https://{0}/OurRemoteEventReceiver.svc",
OperationContext.Current.Channel.LocalAddress.Uri.DnsSafeHost + "/services");
and then use it while adding an event receiver to our target list. A different way of obtaining this remoteUrl is shown in the second post.
When I try to do this I get the below error:
CorrelationId: eb837c4c-c434-4067-99f4-ad9b38e30d82
3> ErrorDetail: The remote event receiver callout failed.
3> ErrorType: Transient
3> ErrorTypeName: Intermittent
3> ExceptionMessage: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from
the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
3> Source: Common
3> SourceName: Common App Deployment
Also, the 'Grant permissions to the App' window appears when I hit Deploy and immediately goes away before I hit or even see the 'Trust it' button. Then, after a while I get the above error in output window. This happens whenever I add the 'AppEventReceiver.svc'
by selecting 'AppInstalled' property to True and then write any code(or even not write any code) in it that targets the host web. Any suggestions please?Hi,
We can add the code snippet below in the "App Installed" event handler.
EventReceiverDefinitionCreationInformation eventReceiver = new EventReceiverDefinitionCreationInformation();
eventReceiver.EventType = EventReceiverType.ItemAdding;
eventReceiver.ReceiverAssembly = Assembly.GetExecutingAssembly().FullName;
eventReceiver.ReceiverClass = "OurRemoteEventReceiver";
eventReceiver.ReceiverName = "OurRemoteEventReceiver";
eventReceiver.ReceiverUrl = "http://xxx/OurRemoteEventReceiver.svc";
eventReceiver.SequenceNumber = 1000;
Web web = SPutil.getSP("http://sub.domain.com/sites/apps");
List targetList = web.Lists.GetByTitle("Host Web List");
targetList.EventReceivers.Add(eventReceiver);
web.Context.ExecuteQuery();
You will need to include an additional .NET class as well:
using System.Reflection;
If the problem still existed, I suggest to debug your remote event receiver project to find the cause of the error. The link below for your reference:
http://blogs.msdn.com/b/officeapps/archive/2013/01/03/debugging-remote-event-receivers-with-visual-studio.aspx
More information:
Add list item properties with a remote event receiver
http://code.msdn.microsoft.com/office/SharePoint-2013-Add-list-2c6e71e0
Best Regards,
Dennis Guo
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Fire event receiver after update list items with PowerShell
Hi,
I have a list with a event receiver attached to it. Also I have a PowerShell script which updates some elements. I noticed that the Event Receiver is not firing after the PowerShell script runs. Is there any way to make it happen?
Thanks anyway!Hi,
According to your description, my understanding is that the event receiver not fire after you update the item elements.
I suggest you can create a simple event receiver and then test if the event receiver fire after PowerShell run.
Here is my PowerShell script:
$spWeb = Get-SPWeb -Identity http://sp2013sps/sites/test
$spList = $spWeb.Lists["Documents"]
$spItem = $spList.GetItemById(14)
$spItem["Title"] = "Test111"
$spItem.Update()
Here is my event receiver code:
public override void ItemUpdated(SPItemEventProperties properties)
base.ItemUpdated(properties);
Console.WriteLine("event receiver has been done");
After the PowerShell run, it will come out the result:
It means the event receiver has been fired.
Here is a detailed article for your reference:
http://blogs.technet.com/b/speschka/archive/2009/12/25/debugging-event-receivers-in-sharepoint-2010.aspx
Thanks
Best Regards
Jerry Guo
TechNet Community Support -
I have two computers. One contains a folder of bookmarks that I want to transfer to the other computer and add it in. I don't want to replace all my bookmarks on the second computer with those from the first computer. How do I do this?
Which kind of backup did you do? A backup from the Bookmarks Organizer or a backup using the program MozBackup?
If you used MozBackup, you need to install it on the new computer to decode the backup. http://mozbackup.jasnapaka.com/
If you used the Bookmarks Organizer, you might just need to add .json to the end of the file name. -
Event Receiver to get folder Names from List View Web Part
Hi,
We have a requirement i.e.
On one of the page,there are some folders on the list view web part.
Now through event receiver i should pick the folder names from list view web part and
update the same in the list.
If that names already exists in the list then we should leave without updating,if not we have to add folder name in the list.
Please share your ideas regarding the same.
Regards,
Naga Sudheer M
Thanks & Regards, SudheerHello,
LVWP is just for displaying content of site so you need to associate your event receiver with actual list/library. You can create ItemAdded event receiver to check existing folder and create new if not existing. "sk2014" links are good to start.
http://sharepoint.stackexchange.com/questions/59788/change-name-in-itemadding-event-receiver-or-create-a-new-item
Let us know in case any doubt
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Can't access community members list in event receiver when item is updated in console application
Hi,
we attached an event receiver to a list in a community site template. In the ItemUpdated event we access different lists from the site. Everything is working fine when we update a list item in the web frontend logged in as Administrator (application pool
identity Administrator).
Updating an list item in a console application running as Administrator triggers the ItemUpdated event and accesses all lists - only the Community Member list can't be accessed.
SPWeb spWeb = properties.OpenWeb();
Guid communityMembersListGuid = new Guid("3b56d08b-be6b-408b-a2aa-c08722ad499b");
SPList communityMembersList = spWeb.Lists[communityMembersListGuid];
We added the Administrator with full access to the list, run the code with RunWithElevatedPrivileges and initialized the spSite with the account-token of the administrator. Nothing works.
Any idea?
Greetings PeterHi,
Please try to use the following code blow:
SPWeb spWeb = properties.Web;
SPList communityMembersList = spWeb.Lists["Community Members"];
If the issue still exists, I suggest you debug your code and provide the detail error message for further research.
Best Regards
Dennis Guo
TechNet Community Support -
Email through Event receiver in SharePoint Online
Hi,
I am creating an event receiver for custom list which will send email to users in sharepoint online.
I am using the following code to send email through event receivers in sharepoint.
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress("[email protected]");
mMailMessage.To.Add(new MailAddress("[email protected]));
mMailMessage.Subject = "subject1";
mMailMessage.Body = "just a body";
mMailMessage.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com", 587)
Credentials = new NetworkCredential("[email protected]", "****"),
EnableSsl = true,
UseDefaultCredentials = false,
client.Send(mMailMessage);
NOTE: I am using MailMessage() because it is in the sandbox solution.
However I am facing the following error :
Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
It may be because I am trying to use SMTP server of sharepoint Online,However I am not able to connect it.
Can anybody help me and can advice how to send email programmatically from sharePoint online ?
Thanks
JhalakIn Office 365, there's no direct way to send an email programmatically because the SPUtility.SendEmail
Method isn't available in sandboxed solutions. The workaround is to use the Send an Email action in a list workflow.
For further detail: http://visualstudiomagazine.com/blogs/tool-tracker/2012/04/send-an-email-in-office-365.aspx -
Event Receiver for all Page Libraries in a Site Collection
We have a single site collection with many different page libraries. I'd like to create a single event receiver for ALL page libraries in the site collection (850- Page Library). Can you do this?
The event receiver will essentially remove/expire something we have stored in the System.Web.HttpRuntime.Cache. We are caching the content in the Page Library and would only like to expire the cache when a new page or change is performed on some
content in the page library.Hi,
We can create a new feature and add an event receiver to the feature for all Page Libraries.
For more information, you can see the link below:
http://msdn.microsoft.com/en-us/library/ee231604.aspx
Here are two similar threads for you to take a look at:
http://sharepoint.stackexchange.com/questions/37555/how-to-add-event-receivers-to-all-the-lists-in-a-site-collection
http://social.technet.microsoft.com/Forums/en-US/f1297543-9035-49d6-9299-d82f546eeddd/event-receiver-for-specific-list-fires-for-all-lists-on-site-collection?forum=sharepointcustomizationprevious
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support -
Disable event firing while updating list item in custom timer job
Hi
I am adding new items in the list usign custom timer job.
While adding the items in the list event receiver of another list (which is not related to list which is updating) is getiing fired due to which I am getting data wrongly updated and exceptions are comming.
why the another lists event recevier is executing while updating my list?
How can I disable event firing from timer job code?
please suggest any solutionHello,
It seems you have deployed your event receiver globally and it is applied to all the lists. I can suggest two ways:
1. Either you update your event receiver feature.xml file and attached to specific list, wherever you want. You can follow below link to attach event with specific list via code:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverdefinition.aspx
Or instead of code you can also pass ListUrl in feature.xml file:
http://msdn.microsoft.com/en-us/library/ff398052.aspx
2. OR delete event receiver from the list: You can use below code in your timer job to delete event receiver
http://sarangasl.blogspot.in/2009/11/remove-event-receiver-in-sharepoint.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
After migration from SP2010 to SP2013 event receiver code is not working
we have two lists work order list and estimation list. we developed infopath form for work order list , in that we have work order field we don't enter the value of that field after filling the all fields when i clicked save button work order ID field
will generate automatically and estimation hyper link will generate.when i click on estimation link estimation list will open, inthat list we have work order id filed it has to generate automatically(It will fetch the data from work order list). For generating
automatically we written event receiver code in visual studio 2010.After migration from SP2010 to SP2013 it is not working. May i know what modification we have to dotry these links:
http://sharepoint.stackexchange.com/questions/75491/sharepoint-2013-event-receiver-on-custom-list-definition-not-firing
http://www.sharepointdiary.com/2011/08/fix-missing-event-receivers-issue-in-migration.html
http://stackoverflow.com/questions/28298707/we-have-event-receiver-code-issue-after-migration-from-2010-to-2013
https://www.linkedin.com/groups/SharePoint-migration-designer-workflow-runs-3664766.S.5905212303858479106
http://channel9.msdn.com/Series/Reimagine-SharePoint-Development/Migrating-a-SharePoint-Event-Receiver-to-a-Remote-Event-Receiver
Please mark as answer if you find it useful else vote for it if it is close to answer..happy sharepointing -
Add post in Newsfeed using sandbox solution
Hi.
How to add post in newsfeed using C# with sandbox solution 2013.
Or
How to add post in newsfeed using javascript without .Net frame workhttp://msdn.microsoft.com/en-us/library/office/jj164025%28v=office.15%29.aspx// Create the post content.var postCreationData = new SP.Social.SocialPostCreationData();
postCreationData.set_contentText('The text for the post, which contains a {0}.');
postCreationData.set_contentItems(socialDataItems);
If this helped you resolve your issue, please mark it Answered -
Web Part Error in Sandbox solution
Hi, I used the following code for "ADD POST IN NEWSFEED USING C#" in sandbox solution 2013.
string serverUrl = "http://sanchit:5097/";
string accountName = @"tafecorp\spservices";
SocialDataItem userMentionLink = new SocialDataItem
ItemType = SocialDataItemType.User,
AccountName = accountName
SocialPostCreationData postCreationData = new SocialPostCreationData();
postCreationData.ContentText = "{0} does great work!";
postCreationData.ContentItems = new SocialDataItem[1] { userMentionLink, };
try
ClientContext clientContext = new ClientContext(serverUrl);
SocialFeedManager feedManager = new SocialFeedManager(clientContext);
feedManager.CreatePost(null, postCreationData);
clientContext.ExecuteQuery();
lblReport.Text = "The post was published";
catch (Exception ex)
lblReport.Text = ex.ToString();
When i run the code the following error comes. How to solve this issue. Thanks in advance.
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred. Correlation ID: 5f639c9c-7639-50f3-7dce-34ae387d3ed0.Share the details about correlation ID in ULS logs
http://sharepoint.stackexchange.com/questions/59679/sandbox-unhandled-exception-was-thrown-partial-trust-app-domain
Well it's taken a few days but I've finally managed to work this one out however it did involve me having to dissect the whole project and reintroduce each piece one at a time.
A few issues were causing it:-
1) I had set one of the projects "Include Assembly in Package" property to false.
2) A static method was making a call to an SPList which turned an empty (null) value. Added a value to that item and the error disappeared.
3) I'd declared a variable as being of type double and set its default value as 0.
Now why the system couldn't have told me that's what the problems were rather than throwing this generic error is a different story! It would have saved me many an hour of confusion.
http://stackoverflow.com/questions/3905388/sharepoint-2010-sandboxed-webpart-error
http://social.technet.microsoft.com/Forums/sharepoint/en-US/c11ab5df-562e-43b4-b350-5c4d07da8bf3/sandbox-solution-error-unhandled-exception-was-thrown-by-the-sandboxed-code-wrappers-execute?forum=sharepointgeneralprevious
http://sohilmakwana.wordpress.com/2013/11/29/sandbox-error-unhandled-exception-was-thrown-by-the-sandboxed-code-wrappers-execute-method-in-the-partial-trust-app-domain/
If this helped you resolve your issue, please mark it Answered -
Sandboxed solution file attachement
Is it possible to attach a file in a list using Sandboxed solution??
please suggest how can we do that through code(c#)By default the answer is no. You cannot.
Here is something previously bookmarked for uploading via the Client OM, this code should be Sandbox compatible.
http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx
You can also try below
http://www.microsofttechnology.net/2013/10/attach-file-to-sharepoint-list-item-by.html -
hi,
I have a requirement: in my site collection i have an announcement list. and in my site collection some 600+ sub sites exist. sharepoint admin uploads an announcement into this rootweb's announcement list. now is there any way
i can add the same announcement -which has title, description, date time etc .- to all the 600+ sub sites' announcement list?
i know , if i write a list item event receiver i will be able to iterate through eacha nd every subweb of my site collec and add this item into those sub web's announcement list. But, without writing an event receiver and creating and deploying
another wsp and avoiding all those headache, is it possible to achieve this requirement?
any other approaches are highly appreciated!Hi,
As a workaround, we can create a winform application for admin use only to add the item to all the sub web's announcement list.
Developing Sharepoint Windows Forms
http://www.codeproject.com/Tips/566370/Developing-Sharepoint-Windows-Forms
Best Regards,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
List Item event receiver not working: SharePoint 2010
Hi,
I have ceated one custom list and also created a Event reciever solution using Visual Studio 2010.
In the event reciever I added ItemAdded, ItemUpdated events and did some my business related coding.
It was worked very well when I add/edit the list item.
But, now suddenly it stopped working!, I i really don't know what went wrong suddenly.
Only thing I did is, created one more solution event reciver and added some more columns to the list.
I then reverted all these changes and deleted the new event reciever from the site solution.
I am able to build and deploy the solution in VS 2010, and I could see the solution in site solution but events are not firing when I created/edited the list items
Any idea what went wrong and how can I get it back to work.
It has spoiled my all the work and I am unable to proceed.
Please let me know if anyone have any inputs.
I also tried following things: restart visual studio and deploy again, restart IIS, restart system itself, actvate-deactivate solution manually in site, GAC the dll manually.
But nothing has worked for me.
One more thing, I am using this solution as Sandbox solution and when I tried to make Sandbox as false and then deploy it gave me error like:
"Error occurred in deployment step 'Activate Features': Operation is not valid due to the current state of the object."
Is this something related to my above problem?
Thanks, SharathCheck Event receivers using powershell:-
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$spWeb = Get-SPWeb -Identity "sitename"
$spList = $spWeb.Lists["yourlistname"]
$spList.EventReceivers | Select assembly,name
Replace "sitename" with your site url and "yourlistname" with list name.
Once you confirm the event receivers, use below to delete them
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$spWeb = Get-SPWeb -Identity "your site url"
$spList = $spWeb.Lists["TrackTravel"]
$evts = $spList.EventReceivers | where {$_.Assembly -eq ""your assembly"}
$evts
if ($evts.Count -gt 0) {
foreach ($evt in $evts) {
Write-Host("Deleting..." + $spList.RootFolder.ServerRelativeUrl + ", " + $evt.Type)
$evt.Delete()
Once you run this, you can now redeploy your solution.
http://social.technet.microsoft.com/Forums/en/sharepoint2010general/thread/a911a64f-b4cb-49a8-ad61-899d4e418c2a
ganesh
Maybe you are looking for
-
IMac 27 Late 2009 with Random black screen at startup of Windows 7!
Hi, I'll try to explain the my random black screen issue as best I can. I have a boot camp partition with Windows 7 x64 Ultimate installed. I used the USB method to install, all goes well and Windows 7 gets installed, I update drivers, install boot c
-
Matlab script of labview keeps executing multiple times,
i have some code for serial communication in matlab , i want to use it in labview for easier and better gui design. for that i have used matlab script node in labview. it seems that labview keep executing the matlab script but i want labview to execu
-
Hope I can explain this correctly, here goes, I have to do a help desk program for a conversion on a old help desk program, in each record there is supporting documents, but instead of putting this info a clob, the old program has a pointer in the co
-
ESPERANDO A QUE SE COPIEN LOS ITEMS
Por qué aparece esto cuando sincrinizo mi ipad y iphone y núnca termina de sincronizar?
-
RS232 fonctionne avec MAX mais pas depuis Labview
Bonjour, Je dois communiquer en RS232 avec un Xmodus1200 (module GSM). J'arrive à communiquer et à piloter mon module sans problème depuis MAX mais dès que j'essaie depuis LABVIEW, je ne recois qu'une partie du message. Le problème provient plus qu