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.
Similar Messages
-
Modify Excel sheet from the sharepoint 2013 by remote event receiver
Hi,
I am new in sharepoint 2013.Actually i want to update excel sheet (that are stored in sharepoint library) by remote event receiver.
Please help me how to do this.
Thanks
Sanjeev Tiwari
Sanjeev TiwariThe proper response is that it's not possible because Excel Interops are not supported running on a server. The technical answer is that you could find work-arounds including treating it as an Open XML object. In either case, I think you need to develop
the Excel processing component first and then connect to that the external event receiver.
Dimitri Ayrapetov (MCSE: SharePoint) -
REST url to get titles and description for all the lists in HOST WEB.
What should be the REST url to get specific prperties for all the list in host web for SharePoint Hosted Apps.
Hi,
We can use the REST URI below:
http://myAppweburl/_api/web/lists?$select=Title,Description
More information:
How to: Complete basic operations using SharePoint 2013 REST endpoints
http://msdn.microsoft.com/en-us/library/office/jj164022(v=office.15).aspx
Best Regards
Dennis Guo
TechNet Community Support -
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 -
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 MoreChristoffer,
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 -
Hi Geeks,
I have a SharePoint Hosted app and Client Hosted webpart where I can calling a list sitting on HostWeb.
I am using SP.RequestExecutor.js to do this. everything works fine and I am able to see this is in Chrome and FF, But in ie8 I was getting cross domain issue.
I have added this doctype to force the browser to use ie8 standard mode
<!doctype html>
<html>
</html>
Now it started working in ie8.
What I observed is when I deploy the code on to my cloud its working fine but on-prim on my dev box its not working.
Only change between both is on prim Host Web and App Web are "http" and cloud its "https". Is it mandatory that to work SP.RequestExecutor.js on ie8 both the web's should be https?. Please adviseSo much for Mac support. Figured it out on my own.
Update Java from http://support.apple.com/kb/DL1572
Reboot and test Java Plug-ins by http://java.com/en/download/installed.jsp
If the applet wont load do the following: http://support.apple.com/kb/HT5559?viewlocale=en_US
Move current installed plugin to disabled folder. Then force a symbolic link from /System to create a new plugin.
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI .plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
Test Java Plug-ins again http://java.com/en/download/installed.jsp
Should report Version 6 Update 45. Which is what was released from Apple on 04/16. I attempted to install Version 7 Update 21 and it disables the Safari plug-in again. -
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 -
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 -
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 -
SP2013 Remote Event Receivers for Office365 and Custom Web Service
Hello I'm starting to work with remote event receivers for Office365 and I read that the RERs runs only as Provider-Hosted or Auto-Hosted Apps, so If I wanted to implement for example prevent to the user add items to some list, my question is :
is it needed an account in a platform cloud like Azure(to support .net apps) or have a custom server like IIS(with public IP, dns) in order to hosting my WFC service and to be able to manage the events registered into office365 ? or exist another option
to achieve this goal(prevent to users perform some actions) ? please, can you help me to clarify this ?....Hi,
The following articles would be helpful:
Deploying SP2013 provider-hosted apps/Remote Event Receivers to Azure Websites (for Office 365 apps)
http://www.sharepointnutsandbolts.com/2013/07/deploying-sp2013-provider-hosted.html
Remote Event Receiver (RER) for Host Web using SharePoint Provider Hosted App in Office 365/SharePoint Online Environment
http://blog.kloud.com.au/2014/03/13/remote-event-receiver-rer-for-host-web-using-sharepoint-provider-hosted-app-in-office-365sharepoint-online-environment/
About Office 365 questions, you can also post it to Office 365 Forum, you will get more help and confirmed answers from there.
http://community.office365.com/en-us/forums/default.aspx
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 -
On a list item which runs first workflow or event receiver?
I have a list where workflow and event receiver is attached
event handler fires on item updated and added and workflow fires for updating the item or so.
Kindly let me know how the priority goes to each technically
how sharepoint handling this internally
very much thanks in advance.
sudhanshu sharma Do good and cast it into river :)After events (ItemAdded and ItemUpdated) are asynchronous by default and run after the item is added/updated and you can’t tell exactly when it’s done. It's possible the workflow will start before the after event is done.
If you need the workflow to run after the event receiver you can try option 1 below or go with option 2.:
Make the after events synchronous (SharePoint 2010 and up) (link)
Set the workflow to be started manually and in the event receiver’s code start the workflow (link) -
Event Receiver to create a List based on a custom template and on lookup field
Hi
I would like to have an Event Receiver who is firing by addItem in a list calls Seminarliste and is creating each time a new list based on three columns for add.Lists("Title of the list", "Description of the list", "Custom List
Template")
I have a Problem to get the LookupField Title and I am getting a Problem to create a list.
If I debug the code the bold line creates an exception ;(
The following code I have produced:
public override void ItemAdding(SPItemEventProperties properties)
base.ItemAdding(properties);
SPWeb spCurrentSite = properties.OpenWeb();
SPSite siteCollection = new SPSite("http://win-ue32d37ap2n");
SPWeb web = siteCollection.OpenWeb();
SPListCollection lists = web.Lists;
String curListName = properties.ListTitle;
if(curListName == "Seminarliste")
SPListItem curItem = properties.ListItem;
String curItemListName = properties.AfterProperties["Title"].ToString();
String curItemDescription = properties.AfterProperties["Beschreibung"].ToString();
// Lookup field with Option to Chose a template name
String curItemTemplate = properties.AfterProperties["Template"].ToString();
SPListTemplateCollection listTemplates = siteCollection.GetCustomListTemplates(web);
//Error by following line ...
SPListTemplate myTemplate = listTemplates[curItemTemplate];
web.Lists.Add(curItemListName, curItemDescription, myTemplate);
If somebody had a similar problem in the past and could advice it would be most appreciated ;-)
Thanks in advance ;-)
Kind regards Michael DamaschkeIf I understand correctly, the field you use to select the template name is a lookup field? If so, then the problem is the lookup field value is not the name of the template. It is an SPFieldLookupValue, which contains the ID and the string of the lookup.
So you want to separate the template name, like this:
if (item["LookupField"] !=
null)
string fieldValue = item["LookupField"].ToString();
SPFieldLookupValue value =
new SPFieldLookupValue(fieldValue);
int lookupListItemID = value.LookupId;
string lookupListValue = value.LookupValue;
IF you look at the fieldValue above, you will see it is something like an integer, followed by delimiter ;# and then your template name. you can always just parse the string at the ;# as well if you were so inclined.
Maybe you are looking for
-
Zoneinfo bug for Asia/Yekaterinburg and others
Hi! I've just discovered that zoneinfo has incorrect or missing DST settings for most of russian cities up until 31 March, 1981. For example, mktime(3C) returns GMT when tm_isdst flag is set to 1, and other values point to time before 01 Apr 1981. Ho
-
Problems with the Calendar in Palm Desktop 6.2
Hi, The Palm Desktop don't show me the Birthdays in the Calendar, I used the older version of the Palm Desktop and they appeared but not now. Con you give me a reason for this? Thanks! Mariano
-
Beyond knowing that such a facility exists, I have no knowledge about Bridge scripting. Can it be used to modify the standard batch file rename process in Bridge? I would like to rename my Canon Raw images with the date (from EXIF Date Digitised) and
-
Dreamweaver 8 - Issues centering web page
I recently started my own business and am on a budget so decided to design the web page myselt with Photoshop and Dreamweaver 8. It went well except for the fact that my page won't center itself on screens, and b/c I created it on a display that is
-
Can I download onto a second computer?
Does my licensing enable me to download Illustrator on a second computer?