New Task Event

M

MichaelA

Hello All,

I am wanting to run a small macro that runs each time a new task is
created. I assume the right event is "ProjectNewTask" which takes a
project and and ID as parameters. First, is this the right event or
should I use "ProjectBeforeNewTask".

Depending on the name.value of the parent of the new task I then want
to set a custom field to a boolean value.

The event is passing the project itself (pj as project) and the ID of
the task that triggered the event (ID as long).

Now I want to test if the name of the parent task is equal to some
value:

If pj.Tasks.Parent.Name = "Issues" Then '<< This does not
work
SetTaskField Field:="Flag20", Value:="yes", TaskID:=ID
End If

Given the error, I now think that I have to reference the specific
task using tasks(index) but have no way of knowing what the index of
the new task is.

Would anyone know how I could find out the name value of the parent
task when a new task event is triggered? I think I am close.


Thanks and regards
Michael A.
 
M

MichaelA

I solved my own problem here eventually:

If pj.Tasks.UniqueID(ID).OutlineParent.Name = "something" Then

Works a treat...sorry about the fuss.


thanks
Michael A.
 
J

Jack Dahlgren

Are you SURE that works the way you expect? UniqueID does not always match
ID. Insert both the ID column and the Unique ID column. Add and delete and
then add a few tasks.
Then compare the two.

Or try sorting on some value with the "Permanently Renumber Tasks" option
selected.

Both of these will show differences between ID and UniqueID.

-Jack Dahlgren

-------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top