Problem:
By nature, SP workflows runs with 'System Account' and all workflow related tasks have been created & modified by system account. What if, task should be created/modified with current login user who initiated workflow? There is no answer and I searched in a google and no luck.. finally i tried my self with the help of old MSDN article and found a solution.
Solution:
How to capture current login name of the user and assign into workflow propertis?
Here is the code snippet
string username = string.Empty;
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
username = e.Identity;
SPUser user = workflowProperties.Web.SiteUsers[username].ID;
workflowProperties.Item["Checked by"] = user.Name;
workflowProperties.Item.Update();
}
That's it...
Happy programming......
By nature, SP workflows runs with 'System Account' and all workflow related tasks have been created & modified by system account. What if, task should be created/modified with current login user who initiated workflow? There is no answer and I searched in a google and no luck.. finally i tried my self with the help of old MSDN article and found a solution.
Solution:
How to capture current login name of the user and assign into workflow propertis?
Here is the code snippet
string username = string.Empty;
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
username = e.Identity;
SPUser user = workflowProperties.Web.SiteUsers[username].ID;
workflowProperties.Item["Checked by"] = user.Name;
workflowProperties.Item.Update();
}
That's it...
Happy programming......
No comments:
Post a Comment