Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date formatting in emails
#11
These tests would seem to indicate the contrary:

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplate.php#L284
https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplate.php#L288

as there are two evaluation in the same string.
Joe
TSolucio
Reply
#12
I don't see two general workflow functions in a row in these templates.

This is what the templates use:
$(general : (__WorkflowFunction__) uppercase(firstname ) ) $(account_id : (Accounts) accountname)

this is what I want to achieve
am $(general : (__WorkflowFunction__) format_date($date_start,'d. F Y') ) um $(general : (__WorkflowFunction__) substring($time_start,0,5) ) Uhr.

It works with a line break before "um" but it does not when put on one line.
Reply
#13
Ok, I added it to our to-do list
Joe
TSolucio
Reply
#14
Thank you very much.
Reply
#15
I did some additional testing and came up with a way to do it by putting all the operations in one WorkflowFunction call:

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplate.php#L304

Anyway, I also created a ticket to get it working as you propose.
Joe
TSolucio
Reply
#16
It seems this is still an issue. However I found a (very fragile) workaround and just post it here for anybody who is interested:

Goal: have the results of multiple workflow functions in one line of html code in workflow emails.
Problem: If they are not seperated by a line break or several spaces they „eat up” some of the code around, apparently even cannibalizing each other.

I wanted to have a custom field value and a date and time of an event in one line like this:


Quote:special appointment on Dec. 6, 2018 at 6.15 a.m.


The code I used is the following:


PHP Code:
<p>$cf_851 on $(general : (__WorkflowFunction__format_date($date_start,'d. F Y') ) at $(general : (__WorkflowFunction__substring($time_start,0,5) )</p



The result is that the time does not appear at all. So I seperated them on different lines like this:


PHP Code:
<p>$cf_851</p>
<
p>on $(general : (__WorkflowFunction__format_date($date_start,'d. F Y') ) </p>
<
p>at $(general : (__WorkflowFunction__substring($time_start,0,5) )</p


But that's ugly:


Quote:special appointment
on Dec. 6, 2018
at 6.15 a.m.


Seperating the functions in the html source code like this is working if...

PHP Code:
<p>$cf_851 
$(general : (__WorkflowFunction__format_date($date_start,'d. F Y') ) 
at $(general : (__WorkflowFunction__substring($time_start,0,5) )</p

Results in the desired formatting...
...if:
- you do not switch to the wysiwyg editor before saving
- if you never edit the email again without fixing these line breaks at the same time.
Reply
#17
You can try using a 'concat' function, something like this unit test example:

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/expression_engine/VTExpressionEvaluaterTest.php#L141

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplateTest.php#L354

https://github.com/tsolucio/coreBOSTests/blob/master/modules/com_vtiger_workflow/VTSimpleTemplateTest.php#L358
Joe
TSolucio
Reply
#18
Thank you Joe,

I tried this:
$(general : (__WorkflowFunction__) concat( translate(format_date($date_start, 'd. F Y') ) ," um ", substring($time_start,0,5)," Uhr.") )

The result:
19. January 201908:16

Expected result:
19. Januar 2019 um 08:16 Uhr

Have you got any other idea or did I write the function wrong?
Reply
#19
It seems I need to use single quotes.


Code:
$(general : (__WorkflowFunction__) concat ( format_date($date_start,'d. F Y') ,' um ', substring($time_start,0,5),' Uhr.') )


This gives the expected result if I put in an empty space after the function. Probably this needs to be done for parsing the function correctly.

So this:

Code:
<p>Event on <strong>$(general : (__WorkflowFunction__) concat ( format_date($date_start,'d. F Y') ,' um ', substring($time_start,0,5),' Uhr.') ) </strong></p>


results in:

Quote:Event on 19. Januar 2019 um 08:16 Uhr


But the Wysiwyg editor strips the space before the closing strong-tag. So after saving it once the source code of the email is:

Code:
<p>Event on <strong>$(general : (__WorkflowFunction__) concat ( format_date($date_start,'d. F Y') ,' um ', substring($time_start,0,5),' Uhr.') )</strong></p>


Which results in:

Quote:Event on 19. Januar 2019 um 08:16 Uhr/strong>

and the rest of the email is printed bold because there is no closing tag.

How can I make the functions persistent in the wysiwyg editor? Or is there a way to completely disable it? It is quite useless if it behaves like this.
Reply
#20
I just added a couple of tests for this use case, the trick seems to be adding a "separation" character after the workflow function:

https://github.com/tsolucio/coreBOSTests/commit/fc20d04d1cc5abdde484ea7992bd2f52b5718555
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)