DynamicContent Send for Approval

Posted by Community Admin on 04-Aug-2018 18:08

DynamicContent Send for Approval

All Replies

Posted by Community Admin on 24-Sep-2013 00:00

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?

Posted by Community Admin on 27-Sep-2013 00:00

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
        

You can also suppress the security checks before making the changes like so:
dynamicManager.Provider.SuppressSecurityChecks = true;

After the SaveChanges do not forget to set it back to false.

Try those and if you ran into some problems, please don't hesitate to contact us.

Regards,
Ivan A. Petrov
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed