How to assign current date to a d:date type property in a content model?

cancel
Showing results for 
Search instead for 
Did you mean: 
chsun
Active Member II

How to assign current date to a d:date type property in a content model?

Jump to solution

Hi,

I am defining an aspect model:

<aspect name="mt:myAspect">
    <properties>
        <property name="mt:effectiveDate">
            <type>d:date</type>
            <mandatory>true</mandatory>
            <default>(I want to use current date here)</default>
        </property>
    </properties>
</aspect>

Because this property shall be mandatory, the default value cannot be an empty string (the empty string will cause errors). Can you help please?

Thank you!

1 Solution

Accepted Solutions
jpotts
Professional

Re: How to assign current date to a d:date type property in a content model?

Jump to solution

You can write a behavior that sets the property with the current date.

If you are not familiar with behaviors, check out my tuorial on the topic: Implementing Custom Behaviors in Alfresco | ECMArchitect | Alfresco Developer Tutorials 

View solution in original post

4 Replies
jpotts
Professional

Re: How to assign current date to a d:date type property in a content model?

Jump to solution

You can write a behavior that sets the property with the current date.

If you are not familiar with behaviors, check out my tuorial on the topic: Implementing Custom Behaviors in Alfresco | ECMArchitect | Alfresco Developer Tutorials 

cesarista
Customer

Re: How to assign current date to a d:date type property in a content model?

Jump to solution

Hi:

I imagine that from the model point of view you can set an ISO 8601 date by default.

On the other hand, in the Jeff's line, here you have a small customization for doing similar thing with cm:effectivity aspect and cm:to property (in this case the behaviour is for setting one month from the creation date).

GitHub - zylklab/zk-qshared-effectivity: Public url documents (qshared) with effectivity in Alfresco...   

Regards.

--C.

chsun
Active Member II

Re: How to assign current date to a d:date type property in a content model?

Jump to solution

Thanks Jeff Potts, Your tutorial is great. I will study it carefully.

chsun
Active Member II

Re: How to assign current date to a d:date type property in a content model?

Jump to solution

Thanks Cesar Capillas. I will use your code as a reference.