Why custom plugin is not execute when Filed Against is Unassigned on implicit save of attachment?
Hello All,
When I attach an attachment to the Workitem and Filed Against value is Unassigned then on implicit save of attachment (Note : Workitem save is not clicked) custom plugins is not executed But when the value of Filed Against is category type then custom plugin is execute on implicit save of attachment.
For Example :
Team_COSI is Team Area
Category is COSI mapped with Team_COSI team Area
Filed Against = Unassigned and attaching an attachment then custom plugin is not executing on implicit save by attachment
Filed against = COSI and attaching an attachment then custom plugin is executing on implicit save by attachment
Why plugins is behaving like this?
One answer
Apparently your extension is doing it right. Since some version when attaching a file to a work item calls the work item save operation with an IAttachment in the data. This only happens during a safe in the Web UI if there is a category set.
Independent of what these values are (I don't know why it was implemented like this), it is up to you to make sure to not run in your code, if not needed. For example, in this specific case, the data you get is an IAttachment or something. So you have to check that you only run your code, if the correct class/interface is passed and you can safely cast it to what you need.
So check the data and exit your extension if it does not match what you need and exit. I think that is what your code, correctly, does.