Get current Logged in name when workflow task updated

Hi All

Scenario:

I had requirement to create custom workflow for multiple approval process. Workflow is running successfully as per client’s requirement. It needs to update the field named ‘Checked By’ (i.e. type of person and group) by username who checked the document in document library. But here it always written as ‘System Account’ instead of actual username who checked the document (task).

Workaround:

I’ve searched lots to display actual user name instead of ‘System Account’. Finally I’ve found following lines of code to get actual username who checked/approved the task.

Resolution:

string currentusername = string.Empty;

private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)

{

currentusername = e.Identity; //retrns server/username(i.e.loginame)

SPUser user = workflowProperties.Web.SiteUsers[currentusername].ID;

workflowProperties.Item["Checked by"] = user.Name;

workflowProperties.Item.Update();

}

That's it...Hope this will work for you.


Cheers !!