cancel
Showing results for 
Search instead for 
Did you mean: 

default value for 'd:datetime' content type

friedman30
Champ in-the-making
Champ in-the-making
Hi,

I need to set "today" as a default value for a "d:datetime" property field.


<property name="custom:Expirationdate">
         <title>Expiration date</title>
         <type>d:datetime</type>
</property>

Any ideas how to do that??

:roll:

Thanks,

Dror
3 REPLIES 3

gavinc
Champ in-the-making
Champ in-the-making
This can't be done at the model level. There are a couple of approaches though. You could add a behaviour (policy) to the type and set the property when an instance of the type is created: http://wiki.alfresco.com/wiki/Policy_Component

Or if you are using the web client you can configure the property sheet to initialise with today's date rather than null: http://wiki.alfresco.com/wiki/Simple_Customisations#Resetting_Date_Picker_Behaviour

friedman30
Champ in-the-making
Champ in-the-making
Hi Gavin,

i am trying to use the javascript API to set the datetime property

var dateNow = new Date().toGMTString();
     file.properties["custom:AvailableDate"] = dateNow;
     file.save();

the above code fails although the dateNow parameter is fine…

Is there any way of doing this using the javascript API?  :?:

Thanks,

Dror

gavinc
Champ in-the-making
Champ in-the-making
Try setting the property with the actual JavaScript Date object instead of the String representation, for example:

var dateNow = new Date();
file.properties["custom:AvailableDate"] = dateNow;
file.save();