Wednesday, February 2, 2011

Initialize Table Value to a Drop Down List in Sales Quotation Edit Lines - Microsoft Dynamics AX 2009

Today I needed to initialize a bunch of values in the Sales Quotation Edit Lines Form in AX 2009. Basically the form (in Designs) has a Tab Page named Parameters. Within this form you can see the following:

My task was to set the Print Confirmation check box enable property set to false and to set the value of the Reason drop down list to "New Sales Order". A best practice for AX 2009 is to create this logic directly in the Form methods or Tables, rather than setting fields through MorphX.

I decided to do this in the Form Methods by modifying the following methods (New code will have a comment Earias - Date):

1- Class Declaration: Here I added the Extended Data Type named smmQuotationReasonId and the Table smmQuotationReasonGroup as shown:
class FormRun extends ObjectRun
    #localMacro.maxControl 10 #endMacro
    SalesQuotationEditLinesForm     salesQuotationEditLinesForm;
    SalesQuotationTable             salesQuotationTable;
    Num                             parmId;
    Dialog                          dialog;
    NoYes                           printFormletterChoice;
    //Earias - 2/2/2011
    smmQuotationReasonId            reasonId;
    smmQuotationReasonGroup         _smmQuotationReasonGroup;
2- Modified the initParameters method: Here I added an instance of the Check Box control as an object and I set the Enabled and Checked properties to false.

I also instantiated the salesQuotationEditLinesForm with the parameters from the Run Base form as shown below:
void initParameters()
    //Earias - 2/2/2011********************************************************************
    //Don't allow the user to print the Sales Quotation Confirmation as they can do it from
    //the Printout button.
    //Disable the automatic checked of the control PrintFormLetter**************************
    if (salesQuotationEditLinesForm.reasonCode())
        salesQuotationEditLinesForm = element.args().caller().runbase();        if(salesQuotationEditLinesForm)
            switch(salesQuotationEditLinesForm.callerModuleAxapta())            {
                case (ModuleAxapta::SalesOrder)             :
                    select ReasonId from _smmQuotationReasonGroup where
                                _smmQuotationReasonGroup.dataAreaId == 'ago' &&
                                _smmQuotationReasonGroup.ReasonId == 'New Sales Order';
                    reasonId = _smmQuotationReasonGroup.ReasonId;

    //End Earias - 2/2/2011******************************************************************
    transferHours2Forecast.value   (salesQuotationEditLinesForm.transferHours2Forecast());
    transferFees2Forecast.value    (salesQuotationEditLinesForm.transferFees2Forecast());
    transferItems2Forecast.value   (salesQuotationEditLinesForm.transferItems2Forecast());

 I'm trying to think on a better way to create the select statement without having to hard code the New Sales Order value directly into it. I thought on a Enum Value.


  1. I actually realized that I could use the following:

    _smmQuotationReasonId = smmQuotationReasonGroup::find('New Sales Order').ReasonId;

    Also, I will add a new field in the table smmQuotationReasonGroup that will allow me to better narrow down the oprions of these tables given our business process.

  2. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#,, php tutorial, Ms sql server

    Thanks a lot..!


Thank you for your thoughts. Your comment will appear in my blog shortly after review.

Have a great day!