Feeds:
Posts
Comments

4D finally did away with the Modified({fieldname}) command.

I’ve replaced it in our code base with

Old({fieldname})#fieldname

4D recommends using the Form Event and On Data Change event.

Can’t tell you how frustrating it is to find the context of a variable stripped away by a meaningless re-assgiment (login required).

From Clean Code: A Handbook of Agile Software Craftsmanship:

The name of a variable, function, or class, should answer all the big questions. It
should tell you why it exists, what it does, and how it is used

// doing this totally strips away any meaningful context
$my_temp_variable = $employee_salaries[$an_employee_name];
$gross_salary = $bonus_factor * $my_temp_variable;

// hopefully the language constructs allow full variable interaction
$gross_salary = $bonus_factor * $employee_salaries["Fred"]

Sending html e-mails opens a whole can of worms on the many ways e-mail can be viewed. There is also no guarantee your e-mail will look as intended.

Instead of linking to a remote css file that may be blocked, or prompt the user with a scary ‘prevented external content to load’ error message, we can use PHP to pull the file directly. This adheres to the DRY principle and keeps the code base clean.

Use the file_get_contents function in place of linking a style sheet via an html style element.

I would also recommend a try/catch block in case the file_get_contents command fails.

Solution

In head section:

<style type="text/css" media="screen">
	<!-- we do this to embed the file contents into the e-mail.
	<?php echo file_get_contents("../common/css/blueprint/screen.css"); ?>
	-->
</style>