cancel
Showing results for 
Search instead for 
Did you mean: 

Set the default value for a date to the current date

si_hutch
Champ in-the-making
Champ in-the-making
Hi,

I have an aspect with an available from property that is of type d:date. I have made the property mandatory and would like the date to default to the current date upon creation. Is this possible using the <default> tag or could somebody advise me on the best way to achieve this.


<property name="test:availableFrom">
<title>Available From</title>
<type>d:date</type>                 
<mandatory enforced="true">true</mandatory>                  
</property>     
    
Regards

Si
1 REPLY 1

si_hutch
Champ in-the-making
Champ in-the-making
Whilst it may not be the best solution I resolved this by using similar code to that in the "SDK CustomAspect" alfresco example project.

Look at the method

public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
    {
        // Set the count started date
        this.nodeService.setProperty(nodeRef, PROP_COUNT_STARTED_DATE, new Date());
    }

Which shows how the property can be set at the same time that the aspect is added.