Perhaps one of the common customizations in Project Web Access (PWA) in Project Server 2010 would be to add a custom webpart on a Project Detail Page (PDP). This webpart will save some data into a data store such as another SQL server database, a SharePoint List or call some web services.For example, let us say that from within PWA, users need to update the description for a project in an external idea management system.For the sake of discussion, we accomplish this by creating a custom webpart with a description textbox.
We could put a Save button inside the webpart but, that would lead to an inconsistent user interface. The user may get confused between the Save button on the ribbon and the save button in the webpart.
We could trap the Save button event by creating an Elements.xml file with a CommandUIHandler for the SaveProject Command.
We’d put in our own javascript in the CommandUIHandler’s CommandAction. However, doing this would override the Save functionality on the PDP ribbon permanently and only our custom code would get called all the time. The out-of-box (OOB) save functionality would be completely overridden, and clicking the Save button on any OOB PDP or a PDP with OOB webparts would not save any of the data.
The problem is, we need to hook into the Save button, but at the same time, we do not want to override the OOB save. We can accomplish this with PageComponents (thank you Abhishek Kumar (abhiku), Microsoft)Here is what Abhishek said:“I think what you need is to write a PageComponent. These are javascript snippets which you can register to the Ribbon PageManager to listen to commands. Find out the command for the Save button and set your custom page component to listen for it. The PageManager would call your associated function too when the button is clicked.”
Here’s what you need to do
The complete source code can be downloaded from the attachment.
Testing it
What it finally looks like
Note:
This work is excellent. However, I have a question: If our customwebpart is updating a Custom Field from the same project, how could we avoid the pop-up stating that the project may be outdated?
Hi! Nice work!
I wan't to cancel the save event if my validation fails. Do you have an idea how to achive this?
Thank you!
Great Work!
But i have the same doubt...,how should i proceed to cancel the save button event ?
Tks.
Great Work man!!
My doubt is after clicking the save it gets saved.but if i refresh the data gets vanished.any idea to retain the value even after refreshing.>?
How could we avoid the pop-up stating "Initiating custom save with a callback"