Expand my Community achievements bar.

Display pattern for DateTimeField ignored when setting value from script

Avatar

Level 1

Hello,

I have a DateTimeField with Data pattern date{DD.MM.YYYY} and Display pattern date{MMMM}, so it displays its default value "21.05.2011" as "May". Now I'm setting its value from the other field's initialize event:

if (this.rawValue) {
    data.Subform_Footer2.DateTimeField1.rawValue = this.rawValue.match(/\d+\.\d+\.\d+/)[0];

}

Assuming this.rawValue contains text "21.04.2011", the DateTimeField displays "21.04.2011" in preview instead of "April" as specified in Display pattern.

4 Replies

Avatar

Level 10

Hi,

To me it looks like you are passing a string to the date field, rather than a date.

Instead of trying to abstract the month manually in the script, why not pass the whole date through "21.04.2011" and leave the display pattern display the month.

Niall

Avatar

Level 1

Niall, I'm passing exactly "21.04.2011" to rawValue. match()[0] is the entire matched string which contains three dot-separated numbers.

Avatar

Level 1

I just tried to set rawValue to '2011-04-21' and it displayed April. So the problem is Data pattern being ignored, not Display pattern.

Avatar

Level 1

Ok, I've figured it. I have to set editValue, not rawValue.