Showing posts with label Axapta Report. Show all posts
Showing posts with label Axapta Report. Show all posts

Monday, November 7, 2011

Get the active comapny in AX 2009 - curExt()

Use the curExt() function to get the active company in AX;

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = curExt();
Info(CompanyId);
}

You would also use the following with the same results. However, the above is much more elegant.

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = CompanyInfo::Find().DataAreaId;
Info(CompanyId);
}

Take Care!

Wednesday, October 5, 2011

Loop through SELECTED records on an AX Form - AX 2009

We have the ability to loop through SELECTED records on a AX form in X++.

There are many ways to accomplish this in AX, but based on my requirements I made the choice of looping through the selected records in a button's click() method.


CustInvoiceJour                     localCustInvoiceJour;
FormDataSource                      form_ds;
Common                              common
;
 //super();

//Set form data source
form_ds = CustInvoiceJour_ds;

for(common = form_ds.getFirst(true)?form_ds.getFirst(true):CustInvoiceJour_ds.cursor(); 
     common;
     common = form_ds.getNext())
    {

        localCustInvoiceJour = common;

        …Implementation…
    }

Tuesday, August 16, 2011

Ax 2009 SSRS Videos

While looking for some information related to AX 2009 SSRS I found a bunch of videos related to SSRS and AX 2009.

Here is the link:

http://youtu.be/ZIoEZWaiBXI

Wednesday, July 27, 2011

strRem Function - Delete a Character from String - AX 2009

The following code searches a specified string character and deletes it. The cool thing about this function is that it is case sensitive.


str strRem(str text1, str text2)
text1  The string from which to remove characters.
text2 The characters to exclude from the output string.

For example:

strRem("MynameIs","is"); //Returns the string "MynameI".

Thursday, March 3, 2011

Set the Business Relationship Account in the Activities Form

Yesterday I had a requirement that said to pre-populate the Business Relationship Account in the Activities Form field Business Account upon creation of a new activity.

To do this I modified the InitValue() method within the smmActivities Data Source:

Forms > smmActivities > DataSources > smmActivities > Methods > InitValue


To do it I had to make sure that the element that was calling the form was the smmBusRelTable, then I assigned the element record to my smmBusRelTable variable. Finally, upon checking the validity of the record, I assigned the busRelTable.BusRelAccount to the busRelAccount in the smmActivities table.

The code is as follows:


THE FOLLOWING CODE GOES INTO THE FORM INIT METHOD
if (element.args().dataset() == tablenum(smmBusRelTable))
    {
        busRelTable = element.args().record();
        //businessRelationRange.value(smmBusRelTable.BusRelAccount);
    }

This Goes in the smmActivities data source initvalue().
    if(busRelTable.BusRelAccount)
    {
        smmActivities.smmBusRelAccount = busRelTable.BusRelAccount;
    }

Tuesday, March 1, 2011

Set the MarkupGroup from the SalesCreateQuotation Form - Microsoft Dynamics Ax 2009

Today I had a requirement to automatically set the MarkupGroup at the moment a user creates a new Sales Quote in AX.


In the past the user would have had to do this manually but with the following changes in my code this happens in the background.


The place where we want to change this is in the salesQuotationTable.writeCreateQuotation Method. This method can be accessed from:


SalesCreateQuotation Form > DataSources > SalesQuotationTable > Methods > Write



The code is as follows:

Tuesday, February 22, 2011

Save a Microsoft Dynamics AX 2009 report to a PDF file (First Part)

The following code saves an Axapta report to a PDF file. This is the first article of 3. The next article will show how to save the file into a network share and pass a Sales Order dynamically, and the last part will be about attaching the PDF to an Outlook instance and create a dynamic subject. So, the titles of the three articles will be the same foe exception of the text in parenthesis.

In my case, I'm having a lot of problems saving the file to a network file and then to attach it to Outlook. The code below saves the report to a local palce in your computer.

static void Job10(Args _args)
{
   custConfirmJour     custInvoiceJour;
  SalesFormLetter     salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation,  false);
   PrintJobSettings    printJobSettings = new PrintJobSettings();
   Args                args = new Args();
   boolean             prompt = false;
   boolean             printIt = true;
   ;

    printJobSettings.setTarget(PrintMedium::File);
    printJobSettings.format(PrintFormat::PDF);
    printJobSettings.fileName(@'c:\temp\myfile2.pdf');
  
   salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

   select firstOnly custInvoiceJour
       where custInvoiceJour.salesid == '18-062467';

   args.record(custInvoiceJour);
   args.caller(salesFormLetter);

   new MenuFunction(menuitemoutputstr(SalesConfirmation), MenuItemType::Output).run(args);

}