6

I have created an Event Receiver (Farm Solution) in SharePoint 2016 that triggers when an item is added in Task list. I have exclusively specified the ListTemplateId="107" in Elements.xml. This event receiver works fine when I add new item directly through browser in any of the Task list but when an item is added by Workflow in Task list then in properties.ListItem.URL property, first /Lists/Tasks/ is returned which is proper but later /Lists/WorkflowHistory/.... is returned which is very strange. Where as ListTemplateID for Workflow History list is 140. I doubt the problem created here is due to Workflow.

Any help is appreciated.

  • What is the scope of event feature? – SP Developer Aug 19 '17 at 10:18
  • The scope of event receiver is site collection – Zakir HC Aug 19 '17 at 10:28
6

If your event receiver's feature scope is set to "Site", then the "ListUrl" and the "ListTemplateId" will be ignored, and your event receiver will fire on all lists.

Now in your case, Whenever task will be created by workflow at that time task related entry will be also added to correspondence history list. That's why event receiver firing on your history list too & returning history list item url.

So, to fire event receiver on specific list/ list template then set event receiver feature's scope to "Web".

  • Excellent. Understood the issue and I resolved it. After making scope to Web, now the event receiver is working as expected. – Zakir HC Aug 19 '17 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.