SharePoint Workflow history list URL

In this SharePoint tutorial, we will see, how to find the SharePoint Workflow History list in SharePoint Online, SharePoint 2013/2016/2010. And we will see how to create a SharePoint Workflow History list using csom programmatically. If you have created some workflow and you have logged some messages to the Workflow History List, then you might want to have look at the list.

If you’re going the View all site content and try to find the workflow history list, then you will not find that list on the SharePoint site. Because the SharePoint workflow history list is a hidden list.

But you can find the list from the SharePoint designer as well as directly typing an URL.

SharePoint Workflow History List URL

Type the URL like below you will be able to see the Workflow History list.

http://[servername]/[sitename]/lists/Workflow%20History

Or open the site using SharePoint designer and then go to All Files from the Site Objects tab from the left side, you will be able to see the list.

Create SharePoint Workflow History list using csom programmatically

Let us check now how to create a workflow history list using csom programmatically in SharePoint Online. Basically, we will use here .Net managed object model (C#.Net) code in SharePoint Online.

In this particular example, I have created a console application using visual studio 2017 and connecting to a SharePoint Online site.

Create workflow history list programmatically in SharePoint

To work with .Net managed object model (csom) code in SharePoint, we need to add the below two dlls, which you can download from the NuGet package.

  • Microsoft.SharePoint.Client.dll
  • Microsoft.SharePoint.Client.Runtime.dll

Here we are taking both the list title (display name) and name (URL). And we are checking if the list exists with the title. If not exists then we are creating the history list. We need to choose the list template as ListTemplateType.WorkflowHistory whose value is 140.

Here are the username and password, I have saved in the config file.

public static void CreateWorkflowHistoryList(string siteURL)
{
using (ClientContext ctx = new ClientContext(siteURL))
{
ctx.AuthenticationMode = ClientAuthenticationMode.Default;
ctx.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
var web = ctx.Web;
ctx.ExecuteQuery();
ListCollection listCollection = ctx.Web.Lists;
var listName = "OurWorkflowHistory";
var listTitle = "Our Workflow History";
ctx.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == listTitle));
ctx.ExecuteQuery();
if (listCollection.Count > 0)
{
}
else
{
List ourHistoryList;
ListCreationInformation creationInfo = new ListCreationInformation();
creationInfo.Title = listTitle;
creationInfo.Url = listName;
creationInfo.TemplateType = (int)ListTemplateType.WorkflowHistory;
ourHistoryList = ctx.Web.Lists.Add(creationInfo);
ourHistoryList.Update();
ctx.ExecuteQuery();
ctx.Load(ourHistoryList);
ctx.ExecuteQuery();
}
}
}

private static SecureString GetSPOSecureStringPassword()
{
try
{
var secureString = new SecureString();
foreach (char c in ConfigurationManager.AppSettings["SPOPassword"])
{
secureString.AppendChar(c);
}
return secureString;
}
catch
{
throw;
}
}

private static string GetSPOAccountName()
{
try
{
return ConfigurationManager.AppSettings["SPOAccount"];
}
catch
{
throw;
}
}

Once you run the code, you can see the history list got created successfully like below:

sharepoint workflow history
sharepoint workflow history

I hope this will be helpful to create a workflow history list using csom (.Net client object model code ) programmatically in SharePoint 2013/2016/Online.

You may like the following SharePoint tutorials:

In this SharePoint tutorial, we learned about the sharepoint workflow list, workflow history list URL, etc.

>