DynamicContent Send for Approval
I have setup a simple 1 step workflow that requires an admin to approve a new dynamic module (license). I'm trying to allow regular unauthenticated users submit a license and then have the admin approve it.
DynamicContent license = dynamicManager.CreateDataItem(licenseType);
license.SetValue("Title", txtTitle.Text);
license.SetValue("Description", htmlDescription.Text);
DynamicContent masterLicense = license;
DynamicContent tempLicense = dynamicManager.Lifecycle.CheckOut(masterLicense) as DynamicContent;
dynamicManager.SaveChanges();
var contextBag = new Dictionary<string, string>();
contextBag.Add("ContentType", licenseType.FullName);
WorkflowManager.MessageWorkflow(tempLicense.Id, licenseType, dynamicManager.Provider.Name, "SendForApproval", true, contextBag);
masterLicense = dynamicManager.Lifecycle.CheckIn(tempLicense) as DynamicContent;
dynamicManager.SaveChanges();
I'm running into trouble on the MessageWorkflow, the error message is telling me "Authorization failed"
Any suggestions?
Hi Mark,
Thank you for using Sitefinity!
Does the error reproduce when you execute the code while logged in as admin (or a user that can make modifications to the module items)?
If you want to run your logic with authentication you should place it in a method, which you can pass to the SystemManager.RunWithElevatedPrivilege(), as a delegate, so that you can authenticate yourself.
Another thing you could try is to run it in elevated mode like so:
using
(
new
ElevatedModeRegion(dynamicManager))
//your logic here
dynamicManager.Provider.SuppressSecurityChecks =
true
;