Newly Created Content Items Appear as Draft

Posted by Community Admin on 05-Aug-2018 20:27

Newly Created Content Items Appear as Draft

All Replies

Posted by Community Admin on 27-Jun-2011 00:00

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.

Posted by Community Admin on 28-Jun-2011 00:00

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 >>

Posted by Community Admin on 29-Jun-2011 00:00

Seems counterintuitive, but that appears to have corrected the issue.  Thank you, Ivan.

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

Thanks.

Posted by Community Admin on 29-Jun-2011 00:00

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 >>

This thread is closed