Tuesday, June 9, 2015

Adding Verification Logic to a Field

Hi Guys,

There is a common customization task to add some piece of business logic to a field.
Here is the example of adding verification to a Journal Transaction screen.

In short, for certain Accounts (Expense and Income) I will need to check that user entered Customer or Vendor into Journal Transaction screen. Balance Sheet accounts should be skipped.

Here is how it supposed to look like:

Thanks to a reworked Acumatica API documentation, it was not a Rocket Science to develop a simple piece of code below that covers this logic:

Please take note of:

sender.RaiseExceptionHandling<GLTran.referenceID>(e.Row, row.ReferenceID, new PXSetPropertyException(ErrorMessages.FieldIsEmpty , PXErrorLevel.RowError, typeof(GLTran.referenceID).Name));

That identifies where exactly to show a red cross Error.

All the Best,


Monday, June 8, 2015

Sending Mail Issues. SMTP server configuration.

Hi Everyone,

For those using Send Mail functionality in Acumatica, there is almost always a problem with SMTP servers, they may not process your e-mail due to certain conditions are not met.

For example, you may have Office 365 account and willing to add it to Acumatica as a system E-Mail account.

There will be an issue when other persons start sending mails from Acumatica, as Office 365 server require Sender to be exactly your account name or at least a person from your domain.

There could also be a case when you set up Acumatica in your internal domain, and are not willing to expose / connect it directly to a public mail server.

Easiest way to avoid these problems is to install an SMTP Relay server at your office. Well this is not really a hardware box server, just a piece of software running on one of your machines, it could even run on Acumatica server itself, as it does not depend on anything, well at least we don't want it to.

So I was looking for a good candidate for SMTP relay with some "alter" functions on the outgoing e-mails and found this software:  EMailRelay Software

This is not just open source, freeware, SMTP relay. It is also a Message Transfer Agent. Meaning it can change the Envelope of your E-Mail, it can also change the content of the Header or Body of your E-mail.

This is perfectly what we need - to alter "From:" address, in case of Office 365 usage.

Also this software can work as a server. I will not go deep into installation procedures, it is simple enough, just download correct version (32 or 64 bit) then unpack it, run the configurator, it will guide you through simple steps. Put Office 365 Server as a relay server. Make sure port 25 is open for incoming E-Mails. You can also configure it as a service, to run when you log off from the machine.

Now, the most interesting part, altering the body of the message and envelope.

Software comes with 4 examples in JavaScript, that you can use.
What it does: when message is received from Acumatica, but not yet relayed to Office 365 SMTP, there is an option - to run Java Script and alter the content of the E-Mail.

What I have done in my script file, you can make your own file by the way:

Please make sure you added a call into a BAT file that system created for SMTP relay, to invoke these alterations. --filter parameter.

Happy mailing!

All the best,