Reparenting Tasks - A lost battle?

S

Steve and Maria.

Help. We need reinforcements. The battle is going badly. We're in danger of
losing our minds. Maybe our jobs. Probably our minds first, though. Help us.

It started as a simple mission - rearrange a project file's task. The Sarge
said it'd be a walk in the park. The sarge was wrong. Now the sarge is dead,
and we're stranded out here all alone.

Here was our mission; Start with a project like this;

Root Task
-> Task 1
---> Task 2
-> Task 3
---> Task 4

And shuffle it about so that the tasks have different parents;

Root Task
-> Task 1
---> Task 4
-----> Task 2
-------> Task 3

-- basically, a complete reshuffle of the task outline.

Sounded easy in the briefing room, but no plan survives contact with the
enemy. We just weren't equipped. The tools just seem to be lacking from the
API. Everything we'd like to set is read-only; we can't say
"Task.OutlineParent = " or "Task.ID = ".

So, we're having to resort to the nastiest hack -- selecting the tasks using
"Application.SelectRow", and using "EditCopy" and "EditPaste" to move things
into the right position.

I know. It's sinful. It may be against the Geneva convention.

Help. Please. Before we're overrun.

Steve ''Knuckles' Cooper and Maria 'Bruiser' Protopapadaki, Salamander
Recon Division.
 
J

Jan De Messemaeker

Hi,

What I would have taken as a tactic/strategy:
OutlineOutdent the whole lot until all is level 1
Sort on new ID (suppose you can enter that)
OutlineIndent till the desired level is reached

But where you srttand now it may be faster to continue...

Hope this helps
 
S

Steve and Maria.

Hi, Jan. I really appreciate your quick reply.
OutlineOutdent the whole lot until all is level 1

Yep, we can do that.
Sort on new ID (suppose you can enter that)

We think we can put together an appropriate sort key, but it may be
monstrously complex -- we have some fairly complex rules to work on as we
sort out our tree.

So, if there were some other way, we'd be really interested to hear about
it. Anything that lets us take a task from one place to another would be
great. We're looking for some golden function that looks like;

sub MoveTask(originalPosition as Integer, newPosition as Integer)

Or to write our own. With that in place, I think the rest of our problem is
solvable.
OutlineIndent till the desired level is reached

This looks good, again. This we can do.

So, thanks again for outlining a possible solution - it's one I think we
can, with some work on our side, use. But if you have any idea where this
missing function might be, we'd really appreciate it.

Do you have any idea why this function might not be there? We're really
surprised because we would have thought that many people would want to
shuffle their tasks about in Project - that it would be one of the more
common tasks.
 
J

Jan De Messemaeker

Hi,

But if you know the new ID for each old ID, just enter that as say Number1
field and sort with the option renumber:=true... what's so difficult?
 
S

Steve and Maria.

Jan De Messemaeker said:
Hi,

But if you know the new ID for each old ID, just enter that as say Number1
field and sort with the option renumber:=true... what's so difficult?
 
R

Rod Gill

I would use a formula or via to create a new sort order in the Number2 field
and store the original ID in Number1. Create a new outline level in number3.

Resort by Number2 then use number3 to indent tasks appropriately.
 
S

Steve and Maria.

Oh, we love these newsgroups. Sorry, but it ate our post. Here it is, again. ;)

Jan, you asked; "But if you know the new ID for each old ID, just enter that
as say Number1 field and sort with the option renumber:=true... what's so
difficult?"

The difficulty is in creating the new ID for each task. We have a fairly
difficult situation we're trying to manage and generating a sort key is
non-trivial.

OUR SITUATION
=============

Essentially, we have an external system containing an unordered tree of
tasks and subtasks, and we are updating project by pushing that tree of tasks
into the Project outline.

The project file that is accepting these tasks can have it's own tasks
(those not originating from our system) and it can have the results of a
previous update.

So updating the project outline is a matter of;

1) inserting new tasks from our external system into project.
2) reparenting the tasks in project according to the parenting coming
through from the external system.

AN EXAMPLE
==========

So, as an example; our system may contain a hierarchy like this;

-> EXT 1
...-> EXT 2
...-> EXT 3
...-> EXT 4

And our project, before update, may contain some of those, plus some
non-external tasks;

-> Project Root
...-> EXT1
...-> Project task
.....-> EXT 2
.......-> EXT 3
.........-> Project child of ext3.

After our update, we need EXT2 and EXT3, and their children, to be
re-parented underneath EXT1, and EXT4 to be inserted under EXT1, like this;

-> Project Root
...-> EXT1
.....-> EXT 2 (MOVED)
.....-> EXT 3 (MOVED)
.......-> Project child of ext3. (MOVED)
.....-> EXT4 (ADDED)
...-> Project task

THE KEY
=======

Making up a unique sort key for the tasks is a bit of a nightmare, because
we have two different types of data. One is an ordered tree, the other
unordered. Both may have similar elements, but don't need to.

All of this is a simple job if we can issue a series of commands like this;

Reparent(task:=EXT2, newParent:=EXT1)
Reparent(task:=EXT3, newParent:=EXT1)
Reparent(task:=EXT4, newParent:=EXT1)

But defining an ID for each one is the kind of algorithm that looks doomed
to be a maintainence nightmare.

OUR QUESTION
============

Is there really no way to move a task and its children without doing a sort?
That is, treating the tasks like a tree? If we can just get hold of a
function which moves a task and its children, our lives are much, much
easier.
 
J

Jan De Messemaeker

Hi,

If you know where to move you know the next position of a task.
If necessary re-sort for each task, computers are fast enough.
Use sort as the move vehicle.
HTH
 
S

Steve and Maria.

If necessary re-sort for each task

This may be our key. Thanks for your help!
 

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

Similar Threads

New books 10

Top