Try Now
More in this section

Forums / Developing with Sitefinity / DynamicContent Send for Approval

DynamicContent Send for Approval

2 posts, 0 answered
  1. Mark
    Mark avatar
    147 posts
    01 Jun 2010
    24 Sep 2013
    Link to this post
    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;
    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;

    I'm running into trouble on the MessageWorkflow, the error message is telling me "Authorization failed"

    Any suggestions?
  2. Ivan A. Petrov
    Ivan A. Petrov avatar
    8 posts
    09 Sep 2013
    27 Sep 2013
    Link to this post
    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.

    Ivan A. Petrov
    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
2 posts, 0 answered