In this SharePoint tutorial, we will see how to activate “Workflows can use app permissions” in SharePoint online site programmatically using client object model code (csom).
We will use C#.net managed object model code (Microsoft.SharePoint.Client.dll) to activate the workflows can use app permissions.
“Workflows can use app permissions” is site level feature and the feature id for this feature is: “ec918931-c874-4033-bd09-4f36b2e31fef“.
You can check out this MSDN article for know more about the feature id for various out of box features in SharePoint 2013.
Even if you have any issues like “workflows can use app permissions error activating“, you can also use CSOM to activate the feature.
Activate workflows can use app permissions
Below is the full code to activate workflows can use app permissions.
public static void ActivateWorkflowFeature(string siteURL)
{
Guid WebFeatureID = Guid.Parse(“ec918931-c874-4033-bd09-4f36b2e31fef”);
using (ClientContext ctx = new ClientContext(siteURL))
{
ctx.AuthenticationMode = ClientAuthenticationMode.Default;
ctx.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
var web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
var webFeatures = ctx.Web.Features;
ctx.Load(webFeatures);
ctx.ExecuteQuery();
webFeatures.Add(WebFeatureID, true, FeatureDefinitionScope.None);
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 above code, the workflows can use app permissions feature programmatically using CSOM.
You may like following SharePoint designer workflow tutorials:
- SharePoint Designer Workflow 2013 Error: Windows Workflow Foundation, part of .Net Framework 3.0, must be installed to use this feature
- Query list from another SharePoint Online subsite using Rest API and Nintex workflows
- How to hide approve reject workflow approval button from ribbon in SharePoint online using css?
- SharePoint Approved and Rejected buttons not appearing in task form in Visual Studio workflow
- Create a Leave request approval workflow in SharePoint using Out of box workflow
- Create a Leave request approval workflow using Microsoft Flow in SharePoint Online
- Create a Leave Request Approval Workflow using SharePoint Designer 2013
- Sorry something went wrong while adding three-state workflow in SharePoint Online
- Call Web API from SharePoint Online using httpsend workflow activity
In this tutorial, we learned how to activate workflows can use app permissions feature programmatically using CSOM.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com