Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have created a custom approval workflow. The approval task is assigned to user A. But sometimes user B would open the task and approve it. As you can see by the screenshot it says who was assigned (user A) and who actually approved it (user B).

How can we programmatically (C#) get both accounts used for approval?

Screenshot from Workflow history

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I presume you mean the AssignedTo and the ModifiedBy? Assigned to is the assigned user, and when you approve a task it gets put into Modified By.

You get them like:

SPListItem task = taskList.Items.GetItemById(taskID);
string modifiedby = task["Modified By"].ToString();
string assignedto = task["Assigned To"].ToString();

If you want to do something that stores just the Approver, then you will need an event handler or the akin on updating that sets a custom column if the approval has changed.

share|improve this answer

I ended up using a local variable from the Approval task, which contains "Modified by". Then I added a property to my custom workflow action. The property was set by using the variable from the workflow.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.