Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date formatting in emails
#1
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:

Code:
$(general : (__VtigerMeta__) date)
$date_start

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

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

Workflows are totally different, MUCH more powerful and the (near) future of templating email in coreBOS
Joe
TSolucio
Reply
#4
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'))
Reply
#5
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:

format_date(date,format)

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') )

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplate.php#L252
Joe
TSolucio
Reply
#6
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/VTParser.inc:132 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) ) )
Reply
#7
Have you tried with single quotes? all the examples I linked above seem to use those instead of double quotes
Joe
TSolucio
Reply
#8
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”.
Reply
#9
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
Joe
TSolucio
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)