+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Newly Created Content Items Appear as Draft

Newly Created Content Items Appear as Draft

4 posts, 1 answered
  1. Geoff
    Geoff avatar
    89 posts
    Registered:
    02 Mar 2011
    27 Jun 2011
    Link to this post
    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.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    28 Jun 2011
    Link to this post
    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 >>

    Answered
  3. Geoff
    Geoff avatar
    89 posts
    Registered:
    02 Mar 2011
    29 Jun 2011
    Link to this post
    Seems counterintuitive, but that appears to have corrected the issue.  Thank you, Ivan.

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

    Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    29 Jun 2011
    Link to this post
    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 >>

4 posts, 1 answered