Pages

Tuesday, June 29, 2010

When sysMailer.quickSend isn't sending any mails

After rather many hours of debugging and hairpulling, I have figured out that you in order to send mails with sysMailer.quickSend, must have View rights to the security key Adminstration / Daily. You don't need to have access to any of the subnodes however.

The cause is that sysMailer.quickSend in order to find the password to the SMTP server, calls SysEmailSMTPPassword::currentAOSInstance, which again makes a select statement to the SysServerSessions table.

The SysServerSessions table must somehow be linked to the above mentioned security key, because without access to this, AX simply exits the metod on that select statement, just as if it had hit a Return statement - and no errors or other hints about the mail not being sent are displayed.

Monday, June 28, 2010

Coloring individual lines in an Enterprise Portal grid

Here's the code you need in order to color individual lines in an Enterprise Portal grid. The example is carried out in the CustomerListGrid user control.

First add an event handler for data binding of the grid:

if (this.AxGridView1!= null)
{
    this.AxGridView1.RowDataBound += new GridViewRowEventHandler(AxGridView1_RowDataBound);
}
Next add the code controlling the logic of the coloring. In this case lines are colored "beige", if the currency of the customer is "USD":
void AxGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    Microsoft.Dynamics.Framework.Data.Ax.DataSetViewRow dataRow = null;
    string currencyCode;

    if (e.Row != null && e.Row.RowType == DataControlRowType.DataRow)
    {
        dataRow = (Microsoft.Dynamics.Framework.Data.Ax.DataSetViewRow)e.Row.DataItem;
        currencyCode = (string)dataRow.GetFieldValue("Currency");
            
        if (currencyCode == "USD")
        {
            e.Row.BackColor = System.Drawing.Color.Beige;
        }
    }
}
I my personal opinion colored rows are disturbing to the eye, and I would prefer to add an icon to the lines which should have special attention. You can see how to do that on the ActivityListGrid user control.