API Workflow Entry Point - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

API Workflow Entry Point

  • API Workflow Entry Point
  • I created a workflow for event approval before they are published. When I create events using the fluent API, they say they are awaiting approval in the Sitefinity backend, but the role assigned to approve the events has a "Send For Approval" button instead of an "Approve" button.  Is there a property that needs to be set to specify which workflow the new event will enter into?

    Here is my current code:
    App.WorkWith().Event().CreateNew().Do(calEvent =>
            calEvent.ApprovalWorkflowState = "AwaitingApproval";
            // Set event properties
            calEvent.Title = txtEventName.Text;
            // etc...
  • Hi Geoff,
    The problem is that you should notify workflow that the item is moved from one state to another. Here is the code to do that:

    var evntId = Guid.Empty;
    App.WorkWith().Event().CreateNew().Do(e =>
            e.Title = "evv1";
            evntId = e.Id;
    var eventItem = App.WorkWith().Event(evntId).Get();
    var masterId = eventItem.OriginalContentId;
    if (eventItem.Status == ContentLifecycleStatus.Master)
                    masterId = eventItem.Id;
    var contextBag = new Dictionary<string, string>();
    contextBag.Add("ContentType", eventItem.GetType().FullName);

    With this code, you create event item and send message to workflow that you are sending this item for approval.

    Bonny Bonev
    the Telerik team
  • This is what I was looking to do, but unfortunately it doesn't appear to be working.  With this code, I am still having the same issue. The event is created and shows up under events as "awaiting approval", but the users under the role that is qualified to approve the events is unable to approve them.  They can only "Send For Approval".
  • Also, using the posted code, the event now shows up as checked out and if I try to call
    I get the error "Cannot check in item that is not in temp state".

    How do I get the role set to approve events able to approve the created events?
    How do I get the event checked in upon the posted code executing?

  • Hello Geoff,

    I just tried again this code and it worked fine. Are you running the code using a user that is qualified to approve the events? If you are doing this from an admin account, this will probably not work if administrators are allowed to skip this step (Send for approval) because it will not be a valid workflow operation. Try to run this code from a user account with permissions "send for approval" and  "approve".

    Bonny Bonev
    the Telerik team
  • Thank you for pointing that out.  Your posted code does work as expected if not using an Admin account.  Thank you very much, Bonny.

    As a side note, on the workflow settings, "Allow administrators to skip the workflow" is unchecked.  Should this still prevent an administrator user from created events and entering them into the workflow as described in my last post?

  • Hello Geoff,

    Allow administrators to skip the workflow - when true, a user that belongs to Administrators role skip the steps you have defined for your workflow.

    All the best,
    Ivan Dimitrov
    the Telerik team
  • Yes, but can you reproduce the issue described in my last post?  When creating events and submitting them to a workflow programmatically.  I was bringing this up in case it was a reproducible bug that needed to be noted or resolved on your end.

  • Hi Geoff,

    I tried this, but I still can't reproduce your problem. I guess that the issue is fixed. You can try this with Q1 and I hope that you will not experience this problem again.

    Bonny Bonev
    the Telerik team