Document Publish To Default Value

Mark Elliott asked on January 13, 2015 20:48

Is there a way to set a default value for the DocumentPublishTo property for a content item? (eg a date 6 months from the current date).

Thanks!

Correct Answer

Roman Hutnyk answered on January 13, 2015 22:15

Mark,

Sorry, there was a typo. Try please {%AddMonths(CurrentDateTime,6)%} or {%AddMonths(DateTime.CurrentDateTime,6)|(identity)GlobalAdministrator%}

Also I need to admit this will work only when creating new document, existing already has some value there (either some date or just blank).

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on January 13, 2015 20:58

You could create a custom global event handler to do this. Out of the box, I don't believe there is a "setting" or anything like that. But you might look at using a setting with the global event handler so you don't have to modify your code when you decide to make it 9 months.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on January 13, 2015 21:02

Mark,

You may setup following macro as a default value of PublishedTo field : {%AddMonth(CurrentDateTime,6)%}

If you can't see that field on the Fields tab of your document (page) type, you can easily add it using approach described here: https://docs.kentico.com/display/K8/Allowing+users+to+tag+documents+on+the+Form+tab.

0 votesVote for this answer Mark as a Correct answer

Mark Elliott answered on January 13, 2015 21:04

Brenden,

Thanks for the fast response. Will look into doing that. Surprised this is not a capability not built into the system. We have different content types that have life-spans on the site. Our content editors dont want to have to worry about setting the expiration dates on the content when they enter it. Surprised others dont have this issue as well.

0 votesVote for this answer Mark as a Correct answer

Mark Elliott answered on January 13, 2015 21:35

Roman,

Thanks for the response. Tried to set default value of DocumentPublishTo to {%AddMonth(CurrentDateTime,6)%} but that doesn't do anything.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on January 13, 2015 21:48

Mark,

Is works fine for me. What version of Kentico are you using?

Notice, you should not just copy and paste that macro into a field, but use macro editor to enter it: click black triangle between "Default value" label and text box. After you'll save macro text box should change to text area.

0 votesVote for this answer Mark as a Correct answer

Mark Elliott answered on January 13, 2015 21:53

Roman,

We are using v8.1 I am entering that value into the macro editor by clicking on the black triangle. When I save the change and then go to enter a new content item there is no default value in that field. Very perplexing.

0 votesVote for this answer Mark as a Correct answer

Mark Elliott answered on January 13, 2015 22:38

Roman,

Awesome! That works just fine. Thanks!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 14, 2015 04:56

Mark,

Where did you place this macro? By Default, it isn't available for you to set a default value that I've seen. The article Roman provided didn't provide any detail as to where this might be set on a more global level, so I'm curious now.

From what I'm seeing you have to place that macro in the PublishTo field every time you create a new document. This requires user input and interaction. The solution I was providing allows it to be done automatically for any page types you specify.

0 votesVote for this answer Mark as a Correct answer

Mark Elliott answered on January 14, 2015 15:59

Brenden,

I added it to the Default Value of the Document Publish To field in the page type. Now when a user enters a new piece of content of that type it automatically populates the field with that date.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.