Add-ins to get the extended classes in DAX 2009

In AOT if you want to know for specific classes , what all child classes are extending this than have a look in following add-in .

Step1 : Create Job with following code.

static void TST_getExtendedClasses(Args _args)
{
    TreeNode        treeNode;
    SysDictClass    dictClass;
    List            extendedClassList;
    ListEnumerator  listEnumerator;
    SysContextMenu  contextMenu;
    Str             className, message;
    Counter         i;
    ;

    SysContextMenu::startedFrom(_args);

    contextMenu = _args.parmObject();
    treeNode    = contextMenu.first();


    i = contextMenu.selectionCount();

    if (treeNode.AOTparent().AOTname() == "Classes")  // Run only if it's opened from classes node
    {
        while (i >= 1)
        {

            dictClass           = new SysDictClass(className2Id(treeNode.AOTname()));
            extendedClassList   = dictClass.extendedBy();

            if (extendedClassList.elements())
            {
                listEnumerator = extendedClassList.getEnumerator();
                message = strfmt("Class %1 is extended by %2 subclasses.",treeNode.AOTname(),int2str(extendedClassList.elements()));
                setprefix(message);
                while (listEnumerator.moveNext())
                {
                    info(ClassId2Name(listEnumerator.current()));
                }

            }
            else
            {
                info(strfmt("Class %1 is not extended .",treeNode.AOTname()));
            }

            treeNode = contextMenu.next();
            i--;
        }
     }
}

Step2 : Create Menu Item with label as Get Extended classes and point to above job.

Step 3: Add above created menu item to the Menu 'SysContextMenu'.

Now if you do right click on class in AOT , than it should


When you select option Get Extended Classes , you will get the output as
Enjoyyy!!!!!!!!!

X++ Code to check the Invoice marked for settlement

Settlement feature allows you to select the open transactions(Vendor / customer)  and then you can post the payment journal for the same. I mean whenever you post PO or SO , all the payment details  will be sitting in Open transactions.
And these open transaction will be used latter for settlement , when you pay to the Vendor or receive the amount from customer.
Following Job illustrates how to check whether invoice is marked for settlement or not. The reason is if invoice is marked for settlement than those invoices cannot be used for posting in other journals.

For illustration i am using vendor invoices , second parameter (_buffer) should be ledgerJournalTrans , custTable or vendTable record for which you will be going to use the specified invoice.

boolean checkRecordMarked(InvoiceId _invoiceId, Common _buffer)
{

        boolean ret;
        ;
        select vendTransOpen
        join   vendTrans
        where  vendTransOpen.AccountNum == vendTrans.AccountNum &&
               vendTransOpen.RefRecId   == vendTrans.RecId      &&
               vendTrans.Invoice        == _invoiceId;


        specTransManager = SpecTransManager::construct(_buffer);
        ret = specTransManager.existForOtherSpec(vendTransOpen.company(), vendTransOpen.TableId, vendTransOpen.RecId);

        return ret;

}

X++ Code to Create Ledger and Inventory Journal names

Following job creates the journal names for all the different types of Journal type that have been defined in Ledger and  Inventory modules.
These journal names will be used for Posting Inventory and Ledger Journals in DAX.
 
void create_JournalNames()
    {
         
        LedgerJournalType     ledgerJournalType;
        LedgerJournalName   ledgerJournalName;
        Enumerator                  enumerator;
        DictEnum                     dictEnum;
        InventJournalName     inventJournalName;
        Counter                        i;
        InventItemType            inventItemType;
        InventJournalType       inventJournalType;
        str                                 itemTypeTxt;
        ;

        select firstonly numseqTable ;

        dictEnum = new DictEnum(enumnum(ledgerJournalType));

        // This block will loop until the end element of enum
        for (i=0;idictEnum.values();i++)
        {
            ledgerJournalType = str2enum(LedgerJournalType,dictEnum.value2Name(i));

            ledgerJournalName.clear();
            ledgerJournalName.initValue();

            ledgerJournalName.JournalName   = strfmt("%1%2_J",substr(enum2str(ledgerJournalType),1,3),i);
            ledgerJournalName.VoucherSeries = numseqTable.NumberSequence;
            ledgerJournalName.Name          = strfmt("%1 Journal",ledgerJournalType);
            ledgerJournalName.JournalType   = ledgerJournalType;

            if (ledgerJournalName.validateWrite())
                ledgerJournalName.insert();

        }

        dictEnum = new DictEnum(enumnum(inventJournalType));

        for (i=0;idictEnum.values();i++)
        {
            inventJournalType = str2enum(inventJournalType,dictEnum.value2Name(i));

            inventJournalName.clear();
            inventJournalName.initValue();

  
inventJournalName.JournalNameId   =strfmt("%1%2_J",substr(enum2str(inventJournalType),1,3),i);

            inventJournalName.Description     = strfmt("%1 Journal",inventJournalType);
            inventJournalName.JournalType     = inventJournalType;

            if (inventJournalName.validateWrite())
                inventJournalName.insert();

        }

    }

Enjoyyyy X++ Cooding !!!!!

Setup Email Alerts and X++ Code to Send Mail in DAX 2009.

Following steps illustrates how to setup and activate Email Alerts in DAX 2009.

In Ax we have two types of Alerts.
    1 ) Pop-Up Alerts , shown in AX Forms as pop-up windows.
    2 ) Email Alerts , where alert message will be sent to users by mail.  In other words its extended
         version of Pop-up Alerts.

How it Works :
   a ) For every alert ax creates record in SysOutgoingEmailTable and  
        SysOutgoingEmailData.
   b ) Then Email distributor batch(Class->SysEmailBatch->run method)  job reads the message
         from the above table and after validating execute the mail.

Now we will see what all setups are required for activating second type of alert.

Step1 : Activates the Alerts feature for user in options form .
             Go to  Tool-->Options  , set show email alerts  as


 Step 2 :  Set Email Parameters , Administration->Setup->Email Parameters
                 Define parameters like which SMTP  Server to use for sending mails and credentials
                 by which mail will be sent to users.




Step 3 : Add Email distributor batch to BatchJob Queue. This job will be responsible for sending mails to users. So if you are not receiving any email it means u have not scheduled this batch job to run.
             Administration->Periodic->Email-Processing--->Batch
Set the recurrence as No End date and minutes as 15-30 minutes.

Step 4 : Check the Batch Job queue for Email distributor batch job , you should find new record
               in batch queue as
               Basic-->Inquiries-->Batch Job
               For this record Click on Alerts and select check box "Error" . It means whenever this
               batch job fails you will get alert.

Incase of any failure you can debugg SysEmailBatch Class run method .

Step 5: Set up Email Templates and attach to EventParameters.
              Basic -> Setup -> Alerts -> Alert Parameter.

Step 6 :   Job to test whether u have configured correctly or not.
                  static void Mail_Send(Args _args)
                 {

                       EventParameters eventParameters = EventParameters::find();
                      SysUserInfo             sysUserInfo;
                     UserInfo                userInfo;
                     ;

                    // SysUserInfo has Alert and email info
                    sysUserInfo = SysUserInfo::find(curuserid());

                     // UserInfo has the language info
                    //userInfo = xUserInfo::find(false, eventRule.UserId);
                                         
 SysEmailTable::sendMail(eventParameters.AlertTemplateId,userInfo.Language,sysUserInfo.Email);

              
            

Even workflow framework uses same alert setups for sending mails for approval and task notifications.

Cool !!!!!!

Open doc , excel and Pdf in DAX 2009 Form

Hi,

I will be illustrating how we can load files like doc , excel and pdf on forms in Axapta 2009.
Advantages
      1.  You will have control on document like set rights for read only etc.
      2.  User will be in AX Workspace , no need for switching the windows between AX and Doc
           Viewer.

Steps  1.  Create form , add ActiveX Control of type Microsoft Web Browser in Design
            2.  Name the Control as CtrlActiveX
            3.  On Form Init Method , after super ()
                        CtrlActiveX.navigate("filePath");         // you can load URL for browsing

As show below in Image
When you run the form , you will see pdf inside form




Enjoyy File Viewing in DAX 2009.