Freigeben über


Workflow name in workflow history list

This blog post is a contribution from Balaji Sadasivan, an engineer with the SharePoint Developer Support team.

Issue

In order to audit workflows, we require to see the name of the workflow in the history list.

Cause

Currently the workflow history has no provision to show the workflow name.

Workaround

Create a new workflow history list from the schema of the original workflow history list. To the workflow history list add an ItemAdded even handler. In that write the flowing code:

 SPListItem item = properties.ListItem;
 SPSite site = new SPSite("https://<Servername>");
 SPWeb web = site.RootWeb;
 SPList destination = web.Lists["CustWFHistory"];//Custom workflow list
 SPList wrkFlwList = web.Lists["MyList"];//The list where the workflow is located
            
            
 string assocID = item["Workflow Association ID"].ToString();//Copying values from source workflow history
 string templateID = item["Workflow Template ID"].ToString();
 string listID = item["List ID"].ToString();
 string primaryID = item["Primary Item ID"].ToString();
 DateTime dateOccured = (DateTime)item["Date Occurred"];
 Guid instance=new Guid(assocID);
 SPWorkflowAssociationCollection WFCol = wrkFlwList.WorkflowAssociations;
            
          
  
 SPListItem newItem = destination.Items.Add();
 newItem["Workflow Association ID"] = assocID;//Adding them to destination
 newItem["Workflow Template ID"] = templateID;
 newItem["List ID"] = listID;
 newItem["Primary Item ID"] = Convert.ToInt32(primaryID);
 newItem["Date Occurred"] = dateOccured;
           
 foreach (SPWorkflowAssociation wa in wrkFlwList.WorkflowAssociations)
 {
     string silID = wa.Id.ToString();
     assocID = assocID.Replace("{", "");
     assocID = assocID.Replace("}", "");
     assocID = assocID.Trim();
     if(silID==assocID)
         newItem["Workflow name"] = wa.Name;//Getting the workflow name       
 }
 newItem.Update();
 site.Dispose();

The new list will show up with the workflow name, workflow association ID, List ID, date occurred. You can add fields like user ID etc. to the custom list query it from the workflow history list and add it.

Comments

  • Anonymous
    January 01, 2003
    Nice post

  • Anonymous
    November 12, 2015
    Great post from your hands again. I loved the complete article.
    By the way nice writing style you have. I never felt like boring while reading this article.
    I will come back & read all your posts soon. Regards, Lucy.

  • Anonymous
    November 30, 2015
    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    http://showboxandroids.com/showbox-apk/
    http://showboxappandroid.com/
    Latest version of Showbox App download for all android smart phones and tablets. http://movieboxappdownloads.com/ - It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    http://showboxappk.com/showbox-for-ipad-download/
    http://showboxappk.com/showbox-for-iphone/
    Showbox for PC articles:
    http://showboxandroids.com/showbox-for-pc/
    http://showboxappandroid.com/showbox-for-pc-download/
    http://showboxforpcs.com/
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment it doesn't charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android. The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on 'Obscure sources'.