Home

Thursday, May 7, 2015

Dynamics Ax – Display the form with different colors for a particular control value


Create the form and add the combo box and change the enum type to SalesStatus and select the modified write the following code:
public boolean modified()
{
    boolean ret;
    ret = super();
    salesTable_ds.executeQuery();
    return ret;
}
and place the grid attach to the SalesTable and write the following methods on the form
public class FormRun extends ObjectRun
{
    QueryBuildrange     mySalesStatus;
}
public void displayOption(Common _record, FormRowDisplayOption _options)
{
    SalesTable prodtablelocal;
    prodtablelocal = _record;
    Switch(prodtablelocal.SalesStatus)
    {
    Case SalesStatus::Delivered:
    _options.backColor(65535); //Light Yellow
    _options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Invoiced:
    _options.backColor(8421631); //Light Red
    _options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Backorder:
    _options.backColor(65408); //Light Green
    //_options.affectedElementsByControl(Salestable_SalesId.id());
    _options.textColor(12582912);
    Break;
    }
}
public void executeQuery()
{
    ;
    if (comboBox.selection())
        mySalesStatus.value(QueryValue(comboBox.selection()));
    else
        mySalesStatus.value(" ");
    super();
}
public void init()
{
    super();
    mySalesStatus = this.query().dataSourceNo(1).addRange(fieldnum(SalesTable, SalesStatus));
    salestable_ds.executeQuery();
}
=================================================

No comments:

Post a Comment