Replacing a blank field with a custom string in an Acumatica template

Viewed 106

We have created some notification templates to send Sales Order details. The issue is, when the Description is blank, we need to add our custom message. How can we do that?

Here is a code sample:

<foreach view= "Transactions”> 
    If(((Transactions.TranDesc)) != null)
       ((Transactions.TranDesc)) = ((Transactions.TranDesc));
    else
       ((Transactions.TranDesc)) = "Custom Message";
</foreach>
1 Answers

I don't think the template engine has scripting facility.

You should be able to achieve similar results with a custom unbound field that you can use directly in your template:

public abstract class tranDescNotification : PX.Data.BQL.BqlString.Field<tranDescNotification> { }

[PXString(256, IsUnicode = true)]
[PXUIField(DisplayName = "Transaction Description", Visibility = PXUIVisibility.Visible)]
public virtual String TranDescNotification
{
    get
    {
        return String.IsNullOrWhiteSpace(this.TranDesc) ? "Custom Message" : this.TranDesc;
    }
}
Related