Catching server events within VBA code in MS Project 2007

J

jlandry

Hello,

I am tying to catch "Project.Updating" server event fired when a user is
saving a project using MS Project UI. Every time I save a new project,
"Project.Created" event is fired and "Project.Saved" event for an existing
project.

My need is to catch the "Project.Updating" event before project gets saved,
in order to validate some og the Enterprise custom fields that may have been
edited in the "Save" pop up dialog window JUST before user click on the save
commande button in MS Project UI.

If I save a project within PWA Interface, the "Project.Updating" event is
fired as weel as "Project.Updated" and "Project.Saved" events.

My question is: Is this possible that "Project.Updating" event is never
fired when saving operation has been done within MS Project UI?

Thanks for any help.

Regards,

Jean
 
J

jlandry

Hello Rod,

I know already that. If you read my post, you'll see that I am talking about
catching Server eventing, which are occurring in Project server environment,
not in client environment.

What I am trying to understrand is why "Project.Updating" event isn't firing
when saving a Project within MS Project UI while saving it using PWA UI is
firing just fine.

This has nothing to do with ProjectBeforeSafe event which is a client event.

Jean.
 
R

Rod Gill

Project Server events and Project UI events are totally different.

You can't catch a before save in project server and stop it happening if
something isn't right. Only a Project event in VBA can stop a save. My
understanding is that the save job gets queued in project server after which
the user may close the project or even the Project App itself. If you
cancelled the save at the server, all changes could be lost!

I don't know all the Project Server events, but maybe the updating event is
triggered when the project is published rather than saved?

Finally there is no way of communicating with the Project UI from Project
Server to display a user warning. The only way I know to test is by using
Project VBA code (or an add-in) fired by the userform in Project.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
T

Timo Lenz

Hello,

interesting topic! I think canceling the save on the server is not very
good, because of dataloss, but you could change the faulty task or custom
field or something else, and then save it with correct data.

Timo
 
C

Chris Boyd

Hey,

We do not fire the Project Update server event when saving from Project
Client. It only gets fired when calling QueueUpdateProject from the PSI,
which is what PWA uses.

Rod is correct, in order to capture the save event from the client, you are
going to have to use the BeforeSave event in VBA.

An alternative is to use the Publish event on the server because this gets
fired both from PSI applications and Project client, but it may not work for
your scenario.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/
 
J

jlandry

Hello,

Thank you all for your suggestions.

Let me bring a little bit more details about what my need is and tell you
how I finally worked it out in order to reach my client needs.

Always in the context of my client's needs, my only problem was to restrict
the users to edit Enterprise Custom Fields (ECF) values within the "SAVE"
dialog window while saving the project via MS Project UI.

I have already validated all these fields during "ProjectBeforeSave()" event
which is being fired BEFORE the user clicks on the "SAVE" command button. Now
you see me coming...

When the user clicks on the "SAVE" command button, there is no way to
stop/cancel the saving operation which is my need. Before the user "hit" the
save button, he still can edit the ECF values and save them right after.

I don't want the user to commit the changes made to ECF values within that
dialog window, since these values have already been validated twice i.e, on
the closure of the "Project infomation..." dialog window and also during the
"ProjectBeforeSave()" event.

Now, how did I managed to work this out?

I finally found that there is one more/last time possible to catch those ECF
values when the "ProjectBeforeSave()" event of the "ThisProject.cls" class is
being fired. Since I managed to keep a set of my ECF in a global collection
somehow, I am able to compare them at that time and tell the user that
"...his changes made to the ECF will not be considered at this time..." and
replace them with the ones I kept in a collection in order to commit the
project with validated ECF values.

We all know that it is a bit "...stretching the sauce..." but this is what
my client is asking for and since there is no way to cancel the save
operation at that time, I am at least able to push valid ECF values to the
database because, you have to be aware that there is not only Project Server
databases involved in that solution but also Web-ProTime database which is a
non MS timesheet product used by my client.

Having said that, I can at least say that I reached 95% of my aim.

Regards,

Jean
 

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