01-20-2012 09:55 AM
Hi all,
I was trying to adapt the nuxeo studio template for Holiday request and have problem to find the correct syntax for the following:
My document has a customised schema which include two properties with "Date" type.
In my automation chain I want to send a Notification -> Send E mail and ton include those "date" inforamtion.
For the moment, in my mail "message" part, I have used the following syntax: @{Document["SchemaName:date_start"]}
As a result I receive an email with the following (in addition to the reset of the e mail which is OK):
java.util.GregorianCalendar[time=1326668400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Paris",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2012,MONTH=0,WEEK_OF_YEAR=3,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=16,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]
Question is: how to display the date in readable format ??
Thank you
PS: I looked in the documentation but all the examples I found are concerning "CurrentDate" but never for a parameter that belong to a Document schema.
Snarf
01-20-2012 12:34 PM
Hi,
Another (tested succesfuly) solution is to use the Scripting function provided for handling date obejcts:
For instance, the following sequence will update the description field with the date value of the dc:modified property:
Fetch > Context Document Document > Update Property ((value: @{Fn.calendar(Document["dc:created"]).format("yyyy-MM-dd")}),(xpath:dc:description))
In case of writing the email in an ftl template, you can set the value you want to use as a context variable before calling the SendEmail operation, and then access the value you computed before in the Context object
01-20-2012 10:24 AM
Not tested but maybe you can try :
@{new java.text.SimpleDateFormat("yyyy-MM-dd").format(Document["SchemaName:date_start"].getTime())}
01-20-2012 12:13 PM
SimpleDateFormat("yyyy-MM-dd").format(date) need a Date in parameter and not a Calendar, sorry.
01-20-2012 10:44 AM
When using SendMail operation it is easier if you use a message template instead of putting the mail content directly in the "message" argument. Using a mail template enable you to use freemarker and reuse your message in other operations. So create a new Mail Template and link it to the message attribute in your operation (click on the button at the right of the textarea) Then in your mail template you can write this for example:
${Document['dc:modified']?string.full}
This will print the dc:modified date of the document attached to the mail. The ?string.full method is a freemarker method that format the date. You can look here for more formatting options:
http://freemarker.sourceforge.net/docs/ref_builtins_date.html
01-20-2012 12:06 PM
Thanks Clément and bstefanescu
Clément, I tried your method but get a error message concerning the format (I didn't catch it in time)
bstefanescu, your method return me the following error when running the automation chain:
error occured while executing the chain 'ChainBonConges': Expected hash. Document['SchBonConges:date_start']?string evaluated instead to freemarker.core.BuiltIn$stringBI$BooleanFormatter on line 5, column 30 in @inline. Transaction failed
The difference with your recommendation is that I need to access a date that in my schema not dubin core one. I don't know if this make a difference or not so I tried replacing dc:modified by my schema name and properties.
Any guess ??
01-20-2012 12:12 PM
Can you add the full stack trace?
01-20-2012 12:34 PM
Hi,
Another (tested succesfuly) solution is to use the Scripting function provided for handling date obejcts:
For instance, the following sequence will update the description field with the date value of the dc:modified property:
Fetch > Context Document Document > Update Property ((value: @{Fn.calendar(Document["dc:created"]).format("yyyy-MM-dd")}),(xpath:dc:description))
In case of writing the email in an ftl template, you can set the value you want to use as a context variable before calling the SendEmail operation, and then access the value you computed before in the Context object
01-20-2012 01:03 PM
Hi,
I did two things and now it's working so I don't know which one among those are required...
Both actions are:
My final working syntax is the following: Document["SchBonConges:date_start"]
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.