Dynamics AX Blog - Dynamics AX 2012 - Page 21

These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2012« Filter entfernen

RSS-Feed of this version

Open a modal form

To call a modal form, the following code could be used (in clicked()-method of a button):

void clicked()
{
    FormRun formRun;
    Args args = new Args();

    super();
    
    args.name(formStr(MyFormName));
    args.record(SalesLine);

    formRun = classFactory::formRunClassOnClient(Args);

    formRun.init();
    formRun.run();
    If (!formRun.closed())
    {
        formRun.wait(true);
    }
}

Using this code, nearly every form could be opened in a modal way, so you have to close the form first before you will be able to return to AX.


 
 

Open form through code

Below you find some examples, how to open a form through code. Each example has it's own Advantages and disadvantages, but i think there is an example available for the most Scenarios.

static void openFormThroughCode_0(Args _args)
{
    menuFunction menuFunction;
    args args;
    CustTable custTable = CustTable::find('1101');
   
    args = new args();
    args.record(CustTable);
    args.formViewOption(FormViewOption::Grid);
   
    menuFunction::runClient(identifierStr(custTable), MenuItemType::Display, false, args);
}

 

static void openFormThroughCode_I(Args _args)
{
    FormRun formRun;
    args args = new args();
    args.name(formstr(CustTable));
    args.formViewOption(FormViewOption::Grid);
   
    formRun = classFactory.formRunClass(args);
    formRun.run();
    formRun.wait();
}

 
 

Searching for menu items name

In Dynamics AX there is no way to search about a menu items name. So i've created a job, which creates the ability to do so.


 
 

How to use labels contaning line breaks in infolog

Some labels containe line breaks ( ). If you want to use such label in infolog, you should use the function strFmtLB:

// Wrong
info(strFmt("@SYS322576", "AccountsPayableServices", "Allgemeiner Fehler"));

// Correct
info(strFmtLB(strFmt("@SYS322576", "AccountsPayableServices", "Allgemeiner Fehler")));

 
 

AX 2012: Print document through code

With the following job you can reprint an order confirmation by code and have it output as a PDF file.

With the help of similarly named classes such as the SalesConfirmJournalPrint used here, it should also be possible to reprint other documents such as invoices or delivery notes.

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint SalesConfirmJournalPrint;
    set set = new set(Types::Record);
    SRSPrintDestinationSettings SRSPrintDestinationSettings;
    
    // Add record
    set.add(CustConfirmJour::findRecId(5637150827));
    
    // Set printer settings
    SRSPrintDestinationSettings = new SRSPrintDestinationSettings();
    SRSPrintDestinationSettings.fileFormat(
        SRSReportFileFormat::PDF);
    SRSPrintDestinationSettings.fileName(@'c:ab.pdf');    
    SRSPrintDestinationSettings.printMediumType(
        SRSPrintMediumType::File);
    SRSPrintDestinationSettings.numberOfCopies(1);
    SRSPrintDestinationSettings.overwriteFile(true);
    
    // Initalize 
    SalesConfirmJournalPrint = SalesConfirmJournalPrint::construct();
    SalesConfirmJournalPrint.parmPrintFormletter(NoYes::Yes);
    SalesConfirmJournalPrint.parmUsePrintManagement(false);
    SalesConfirmJournalPrint.parmPrinterSettingsFormLetter(
        SRSPrintDestinationSettings.pack());
    
    // Print
    SalesConfirmJournalPrint.printJournal(set); 
}

 
 

hasField()-Method

I had already seen the situation that I wanted to know if a record has a particular field to be able to process the containing value. For example, within a method, which processes the calling args().

For example, in class SysDictTable the hasMethod() method is available, but i have not found a hasField() method so far.

Therefore I've created the following logic:

Common callingRecord;
itemId itemId;
SysDictField itemDictField;

itemDictField = SysDictField::findFieldByName(tableId2name(callingRecord.TableId), identifierStr(itemId));

if(itemDictField)
{
    itemId = callingRecord.(itemDictField.id());
}

 


 
 

AX 2012: SysOperation-Framework: Initalize parameters of a data contract

If you include the SysOperationInitializable class in a data contract using the implements command, the method initialize() gets available and can be overwritten.

This method can be used to initialize variables within the data contract. However, this method is only called as long as no usage data is found or it is not activated.

[DataContractAttribute]
class TutorialSysOperationDataContract
    implements SysOperationInitializable
{
    date dialogDate;
}

 

[DataMemberAttribute]
public TransDate parmDialogDate(TransDate _dialogDate = dialogDate)
{
    dialogDate = _dialogDate;
    return dialogDate;
}

 

public void initialize()
{
    dialogDate = systemDateGet() - 365;
}

 


 
 
Pages « 1 ... 18 19 20 21 22 » 

 

 
 
 
Posts of the actual month
Mai 2024
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Desktop version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.