cancel
Showing results for 
Search instead for 
Did you mean: 

How to access a document schema date parameter from Automation Chains

snarf77_
Confirmed Champ
Confirmed Champ

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

1 ACCEPTED ANSWER

Alain_ESCAFFRE
Star Contributor
Star Contributor

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

View answer in original post

7 REPLIES 7

Clément_Lardeur
Confirmed Champ
Confirmed Champ

Not tested but maybe you can try :

@{new java.text.SimpleDateFormat("yyyy-MM-dd").format(Document["SchemaName:date_start"].getTime())}

SimpleDateFormat("yyyy-MM-dd").format(date) need a Date in parameter and not a Calendar, sorry.

bstefanescu_
Champ on-the-rise
Champ on-the-rise

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

snarf77_
Confirmed Champ
Confirmed Champ

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 ??

Can you add the full stack trace?

Alain_ESCAFFRE
Star Contributor
Star Contributor

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

snarf77_
Confirmed Champ
Confirmed Champ

Hi,

I did two things and now it's working so I don't know which one among those are required...

Both actions are:

  • replacing ' par "
  • deleting the ?string.full

My final working syntax is the following: Document["SchBonConges:date_start"]

Getting started

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.