Pergunta

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.

Foi útil?

Solução

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".

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top