Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date formatting in emails
The new global variable format for $EMail_CustomCurrentDate_Formatseems to work in email templates but not in Workflow email !?

These should be transformed in emails but are not:

$(general : (__VtigerMeta__) date)

Actually any occurence of a date should be put out in the same format which $EMail_CustomCurrentDate_Format should define.

Best regards
I didn't add it in workflows because there is already a way to get each part of the date there, no?
Yes, here: format_date

Workflows are totally different, MUCH more powerful and the (near) future of templating email in coreBOS
Could you please point out how I can use format_date in workflow emails?

I want to send an email with the appointment date in the subject line when the appointment is scheduled.

These do not work:
- format_date('d.m.Y', $date_start)
- $(format_date('d.m.Y', $date_start))
- $date_start(format_date('d.m.Y'))
open the workflow editor (for example clicking on the vaue input in a condition), select expression and then format_date. You will see this syntax:


if you select "date" and insert a field you will see

format_date(date_start ,format)

so this should be what you are looking for:

format_date(date_start ,'d.m.Y')

now, to put that in the body of a text you have to put it inside a WorkflowFunction meta-structure, like this:

$(general : (__WorkflowFunction__) '."format_date(date_start ,'d.m.Y') )
I am using this
$(general : (__WorkflowFunction__) format_date($date_start, "d.m.Y") )

but still get an error: Fatal error: Uncaught Exception: Was expecting a closing bracket in /.../modules/com_vtiger_workflow/expression_engine/ Stack ...

I don't see a missing bracket.

This custom function works and seems to have the same structure:

$(general : (__WorkflowFunction__) __email_begruessung( $(cto_id : (Contacts) salutationtype), $(cto_id : (Contacts) lastname), $(cto_id : (Contacts) cf_833), $(cto_id : (Contacts) cf_836) ) )
Have you tried with single quotes? all the examples I linked above seem to use those instead of double quotes
You are right, but it is not enough.

This one works:
$(general : (__WorkflowFunction__) format_date($date_start,'d.m.Y') )

But only if I add a space after the final bracket. Maybe that is not intended? Took me a while to find out.

PS: Actually I even need to put a dot on the same line in order to preserve the empty space after the function. Otherwise soemthing gets stripped and the function is not executed with error message ”missing bracket”.
It is rather hard to create a unique string inside a string that we can capture and process accordingly. If you look at the examples I sent in the link above you will see those spaces you are talking about.

Glad you got it working
The Wysywig editor is cutting out these spaces in many cases. So adding a free space and a dot after a workflow function seems to be a safe way to get them processed. But there are some cases where a dot is annoying or misleading.

It also looks like it is impossible to have two functions on one line. When I break them up into two lines (with <p></p> tags for each) it works. When I have them on one line the second is just disappearing.

Forum Jump:

Users browsing this thread: 1 Guest(s)