snippet of a workflow design in VS2008 - focus on the two red activities
- Assign a new field to the Executor property of the OnTaskChanged activity in question (you'll see this property in the property window on the activity). Note we use this new field in a later LogToHistoryListActivity's Method_Invoking() by assigning the UserID property of the LogToHistoryListActivity's object
- Add a userid lookup/helper function to guarantee a valid SharePoint user id is in place
private SPUser GetUserObject(string accountID) { try { if (accountID.IndexOf(@"\") > 0) { SPUser user = this.workflowProperties.Web.SiteUsers[accountID]; return user; } else { //replace DOMAIN SPUser user = this.workflowProperties.Web.SiteUsers[@"DOMAIN\" + accountID]; return user; } } catch { //replace DOMAIN and administrator SPUser adminUser = this.workflowProperties.Web.SiteUsers[@"DOMAIN\administrator"]; return adminUser; } }As you assign a new field to each TaskChangedEvent's executor property, you'll see this declaration inserted to the bottom of the workflow class.
public String RVPReviewTaskChangedEvent_Executor1 = default(System.String);
Later when the LogToHistoryListActivity's Method_Invoking event is triggered, you use this new field and the helper function to modify the UserID property on the LogToHistoryListActivity's object;
private void logRVPReviewed_MethodInvoking(object sender, EventArgs e) { SPUser executor = GetUserObject(RVPReviewTaskChangedEvent_Executor1); logRVPReviewed.UserId = executor.ID; }
you can do it, just with this code...
ReplyDeleteContact executor = Contact.FromName(TaskChanged_Executor,workflowProperties.Web);
CurrentWorkflowUserId = executor.PrincipalID;
Great Job.
ReplyDeleteThanks,
Sri