Newly Created Content Items Appear as Draft - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Newly Created Content Items Appear as Draft

  • Newly Created Content Items Appear as Draft
  • 281158_Event-Fluent-API.png
    I'm creating event content items using the following code:
    App.WorkWith().Event().CreateNew().Do(calEvent =>
        eventID = calEvent.Id;
        PopulateNewEvent(calEvent, currentUser);
    )
    .Publish()
    .SaveChanges();

    The events then show up in the Sitefinity back end as a Draft, as shown in the attached screenshot.  Is calling .Publish().SaveChanges(), the recommended process for creating and publishing a new event using the Fluent API?  What are the effects of having the content item created as "Draft" as opposed to "Published"?

    Thanks.
  • Hello Geoff,

    Try using this way

    Guid eventId = Guid.Empty;
    var title = "TestEvent";
    var TestContent = "TestContent";
    App.WorkWith().Event().CreateNew().Do(ev =>
        eventId = ev.Id;
        ev.Title = title;
        ev.Visible = true;
        ev.Content = TestContent;
        ev.DateCreated = DateTime.Now;
        ev.ApprovalWorkflowState = "Published";
    )
    .SaveChanges();


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • Seems counterintuitive, but that appears to have corrected the issue.  Thank you, Ivan.

    I'm curious, what does the .Publish() method do exactly?

    Thanks.
  • Hello Geoff,

    It calls Publish method of the EventsManager which publishes the master state and creates a new version of the item, but this does not update the workflow state that is shown on the label.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>