Question

I have a requirement to show when an item was last approved by an approver and the name of approver. I searched and could find that Approval Status and Approval comments can be obtained by the columns _ModerationStatus and _ModerationComments .

Is there some way I can also get the Approvers name and Approval date of when the item was last approved through C# code?

Any help is appreciated. Thanks.

EDIT

In case that is not possible to get directly , Is it a good idea to use the last "modified date" of the item if the Status is set as "Approved"? Since after approval any changes made to the list item will change the status to Pending.

Correct me if I am wrong.

Was it helpful?

Solution

The below code snippet can be used to get the Approver's Name and the Approved Date for a list Item's last approved version.

for (int index = 0; index < myListItem.Versions.Count; index++)
{
  if (myListItem.Versions[index].Level == SPFileLevel.Published) 
   {
    myVersion= myListItem.Versions[index];   

    Console.WriteLine(
      "Approved Date: {0} {1} Approver: {} ",
      myVersion.Created,
      myVersion.CreatedBy.LookupValue);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top