I’ve been working on a full end-to-end demand management workflow over the past couple of weeks and unfortunately as RTM is due any day now, much of the final documentation is still not public, meaning that some things just need to be figured out.
One problem that I found is the custom workflow task form, which has a very useful "Review project details" link on it. However if you have used Microsoft’s demo2010a image, then you’d see that for all of the workflow’s the link initially does not work. (See image)
Fortunately this one was relatively easy to guess, thanks MS for making it quite obvious!
Firstly a custom workflow task content type called PSWApprovalTask is created by default in the PWA site "Project Server Workflow Tasks" list, here’s what it looks like out-of-the-box:
Interestingly though, it is not by default added to the list content types, BUT if you run through the Sample Proposal Workflow once then you will see it appear in the list automatically. For the purpose of this just use the ‘Add from existing site content types’ option in List Settings to add it:
Now another interesting thing is apparent on the list settings page:
Specifically Microsoft has pre-defined three Columns named: Project Name, Project Owner and ProjectUid (and some others..), however they are not added to the content type by default either, but they are used in the views including the default My Tasks.
To the point:
Now getting to the point of this post, if you use the content type and populate all of those fields then the task approval page will work as expected! Specifically the ProjectUID Column needs to be populated with guess what: the Project’s GUID, once that is done then the link works as expected!
Too easy!
Well unfortunately not. The Visual Studio Workflow Activities included with Project Server 2010 gives you the very handy ReadProjectProperty action, however while having a choice of either reading a Custom Field based on GUID or a pre-defined built in field based on name, it does not include Project GUID. This is where it gets complicated.
The “simple” solution is to use PSI, then using something like this nice little method created by Chris Boyd you can retrieve the GUID by providing the Project Name using PSI method ReadProjectStatus.
Unfortunately having to use PSI in what otherwise could be a very simple SharePoint workflow in my opinion is clunky, it would be very nice if MS could add the Proj_UID property to the ReadProjectProperty action!
If you’re interested, based on Chris’s blog post linked above, here is an extract of my code to get all of those fields working (Note that this plugs in nicely to my last code post: Extending the Branching Workflow):
// Declare your PSI Stuff
private static WebSvcProject.Project project = new WebSvcProject.Project();private void createTask_InitApproval(object sender, EventArgs e)
{
[… insert your other required task attributes …]
taskProps.ExtendedProperties["Project Name"] = Proj_Name[0];
taskProps.ExtendedProperties["Project Owner"] = Proj_Owner_Name[0];
taskProps.ExtendedProperties["ProjectUid"] = GetProjectUidFromProjectName(Proj_Name[0]);
}
public static Guid GetProjectUidFromProjectName(string projectName)
{
Guid projectGUID;
project.Credentials = CredentialCache.DefaultCredentials;
WebSvcProject.ProjectDataSet readProjDs = new WebSvcProject.ProjectDataSet();
readProjDs = project.ReadProjectStatus(
Guid.Empty,
WebSvcProject.DataStoreEnum.WorkingStore,
projectName,
0
);
if (readProjDs.Project.Rows.Count == 1)
{
projectGUID = new Guid(readProjDs.Project[0].PROJ_UID.ToString());
}
else
{
throw new Exception("No Project by the name: " + projectName + " Found");
}
return projectGUID;
}
Enjoy!
Update 4/08/2010:Check the comments below for a much easier way to correct this issue, without the use of PSI.
Hai
The link is not working .
There are a lot of errors.
1 The name ‘project’ does not exist in the current context
2 The name ‘CredentialCache’ does not exist in the current context
3 The type or namespace name ‘WebSvcProject’ could not be found (are you missing a using directive or an assembly reference?)
4 The type or namespace name ‘WebSvcProject’ could not be found (are you missing a using directive or an assembly reference?)
5 The name ‘project’ does not exist in the current context
6 The name ‘WebSvcProject’ does not exist in the current context
Pls Help me
Thanks in advance
iqbalkmk
Hi,
Yes the example is not complete, but I’m assuming you added it to my last example on the Branching Workflow? Those errors are from two additional things that are missing:
1. CredentialCache comes from the namespace “using System.Net;”
2. All of the other errors come from the web service reference which is required and not included in the example above.
The Project Programmability blog has some good articles on getting started with the PSI that should help you out here, like this one: http://blogs.msdn.com/project_programmability/archive/2006/10/16/getting-started-with-the-psi.aspx
Hope that helps,
Hai…Martin
Thank you for giving information..
I tried to solve this but its not working.
Can u give me the full example, if u can?
Thank you in advance
iqbalkmk
Hai…
I got 9 more errors when am trying websvc class.
I can`t add web service it giving following errors.
“There was an error downloading ‘http://expertspm/pwa/_vti_bin/psi/project.asmx’.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: ‘http://expertspm/pwa/_vti_bin/psi/project.asmx’.
The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ‘NTLM’.
The remote server returned an error: (401) Unauthorized.
Hai…
I got 9 more errors when am trying websvc class.
I can`t add web service it giving following errors.
“There was an error downloading ‘http://expertspm/pwa/_vti_bin/psi/project.asmx’.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: ‘http://expertspm/pwa/_vti_bin/psi/project.asmx’.
The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ‘NTLM’.
The remote server returned an error: (401) Unauthorized.
Can u help me..
Thanks in advance
iqbalkmk
Hai Martin.
Finally i solved the above problem.
I just used the url like http://servername/pwa/_vti_bin/psi/project.asmx?wsdl
its works fine.
Thanks in advance
iqbalkmk
Thanks Martin for Sharing this.
As quick workaround, we can get the ProjectUid from the WorkflowContext Property of the ProjectSequence Activity, without having to query the PSI Api.
Example:
taskProps.ExtendedProperties[“ProjectUid”] = this.ProjectSequence1.WorkflowContext.ProjectUid;
It worked well for me.
Thanks
Lakshman
Hi, Thanks for the tip, I noticed this after RTM when browsing the SDK content and I was sure I updated the blog with some more info. But you’re spot on the use of PSI (and 2007 methods at that) is completely unnecessary to fix this issue!
Hi martin,
Thank you for advising me.
I have another scenario for me.
I need to add more approval options in pwsapproval task form like Approve/Reject/Rework to initiator etc..
How can i create new approval task content type using ribbon?
I tried to create content type but i dont know how to add ribbons in edit form and integrate in workflow.
I think some others have same scenario..
Can you help me?
Thanks in advance
iqbalkmk
Hi Martin,
How to to create button and click event to be fired and move to next stage in edit workflow approval task where approve and reject button exist in ribbo.
Thanks In Advance
John
Hi Martin,
How to create button and click event to be fired and move to next stage in edit workflow approval task where approve and reject button exist in ribbon
Thanks In Advance
John