A
Andrzej Jaworek
Hi All,
Based on this article:
http://msdn2.microsoft.com/en-us/library/bb802729.aspx
I've created an event for adding a new task. Before adding a new task
(via My Task-> New -> Task) after clicking Send button on adding new
task form, my event code cheks some conditions and set e.Cancel =
true/false based on my conditions.
To do this I've created a class:
public class TaskCreatingEventHandler : StatusingEventReceiver
{
public override void OnTaskCreating(PSContextInfo contextInfo,
StatusCreateTaskPreEventArgs e)
{
base.OnTaskCreating(contextInfo, e);
//here I have my conditions.
//If my conditions are not passed I'm setting
//e.Cancel = true
}
}
On Server-Side Event Handler Configuration in PWA I've attached this
program to Statusing > TaskCreating event.
After making sure that the event is installed, I've run Visual Studio
debugger, attached to the process and set breakpoint on the begining of
the OnTaskCreating method.
After that I've clicked on My Task then New, then Task. On adding a new
task form I've filled all required fields (I've entered values that do
not pass my conditions) and clicked Send. VS Debuger has stoped on my
breakpoint.
I've went through the whole code step by step to check if my conditions
are working fine. Everything was fine : e.Cancel = true is set. After
finishing running the whole code I've returned to the PWA and realised
that the red info was displayed on the adding new task form. I was sure
that everything was ok and that the new task was not added. But when
I've returned back to the My task directory I've seen that my task was
added and was visible on the My task grid.
Why? How to cancel adding a new task via event handler?
Please help.
Andy
Based on this article:
http://msdn2.microsoft.com/en-us/library/bb802729.aspx
I've created an event for adding a new task. Before adding a new task
(via My Task-> New -> Task) after clicking Send button on adding new
task form, my event code cheks some conditions and set e.Cancel =
true/false based on my conditions.
To do this I've created a class:
public class TaskCreatingEventHandler : StatusingEventReceiver
{
public override void OnTaskCreating(PSContextInfo contextInfo,
StatusCreateTaskPreEventArgs e)
{
base.OnTaskCreating(contextInfo, e);
//here I have my conditions.
//If my conditions are not passed I'm setting
//e.Cancel = true
}
}
On Server-Side Event Handler Configuration in PWA I've attached this
program to Statusing > TaskCreating event.
After making sure that the event is installed, I've run Visual Studio
debugger, attached to the process and set breakpoint on the begining of
the OnTaskCreating method.
After that I've clicked on My Task then New, then Task. On adding a new
task form I've filled all required fields (I've entered values that do
not pass my conditions) and clicked Send. VS Debuger has stoped on my
breakpoint.
I've went through the whole code step by step to check if my conditions
are working fine. Everything was fine : e.Cancel = true is set. After
finishing running the whole code I've returned to the PWA and realised
that the red info was displayed on the adding new task form. I was sure
that everything was ok and that the new task was not added. But when
I've returned back to the My task directory I've seen that my task was
added and was visible on the My task grid.
Why? How to cancel adding a new task via event handler?
Please help.
Andy