Dynamics AX Blog - Dynamics AX 2012 - Page 15

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

Print packing slip through code

The following job demonstrates, how you can print an existing Sales packing slip through code. The example sends the report to screen.

static void printSalesPackingSlipThroughCode(Args _args)
{
    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustPackingSlipJour::findRecId(5637161120));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct();
    salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesPackingSlipJournalPrint.parmUsePrintManagement(false);
    salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesPackingSlipJournalPrint.printJournal(set);
}

Changing the parameter of the instance of SRSPrintDestinationSettings allows you to send the sales packing slip to printer, file or mail. The next example creates a PDF-file.

static void printSalesPackingSlipThroughCode(Args _args)
{
    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustPackingSlipJour::findRecId(5637161120));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
    srsPrintDestinationSettings.fileName(@'c:	emppackingslip.pdf');
    srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
    srsPrintDestinationSettings.numberOfCopies(1);
    srsPrintDestinationSettings.overwriteFile(true);

    // Initalize
    salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct();
    salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesPackingSlipJournalPrint.parmUsePrintManagement(false);
    salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesPackingSlipJournalPrint.printJournal(set);
}

If you want to print multiple sales confirmations at once, you have to add the corresponding CustPackingSlipJour-records to the set called "set:

    ...    
    // Add record
    set.add(CustPackingSlipJour::findRecId(5637155842));
    set.add(CustPackingSlipJour::findRecId(5637145354));
    ...

To additionally save the sales packing slip to print archive, you can add the following line:

    ...    
    srsPrintDestinationSettings.parmPrintToArchive(true);
    ...

 
 

Create primary address through code

The following lines show an example of how you can create a (primary) address for an existing party in the global address book by x ++ code.

The address will only be marked as primary, if no other primary address exists for this party!

static void createPartyAddress(Args _args)
{
    DirPartyTable dirPartyTable = DirPartyTable::findByNum("???100000");
    DirParty dirParty;
    DirPartyPostalAddressView dirPartyPostalAddressView;

    // Create instance of dirParty
    dirParty = DirParty::constructFromCommon(dirPartyTable, DirUtility::getCurrentDateTime(), dirPartyTable.partyType());

    // Create primary address
    dirPartyPostalAddressView.LocationName      = "Office";
    dirPartyPostalAddressView.City              = "Vienna";
    dirPartyPostalAddressView.Street            = "Kärtnerring";
    dirPartyPostalAddressView.StreetNumber      = "18";
    dirPartyPostalAddressView.CountryRegionId   = "AUT";
    dirPartyPostalAddressView.IsPrimary         = NoYes::Yes;

    dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
}

 
 

Print sales confirmation through code

The following job demonstrates, how you can print an existing Sales confirmation through code. The example sends the report to screen.

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustConfirmJour::findRecId(5637155842));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesConfirmJournalPrint = SalesConfirmJournalPrint::construct();
    salesConfirmJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesConfirmJournalPrint.parmUsePrintManagement(false);
    salesConfirmJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesConfirmJournalPrint.printJournal(set);
}

 
 

Print purchase order through code

The following job demonstrates, how you can print an existing Purchase order through code. The example sends the report to screen.

static void printPurchaseOrderThroughCode(Args _args)
{
    PurchPurchOrderJournalPrint purchPurchOrderJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(VendPurchOrderJour::findRecId(5637179849));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    purchPurchOrderJournalPrint = PurchPurchOrderJournalPrint::construct();
    purchPurchOrderJournalPrint.parmPrintFormletter(NoYes::Yes);
    purchPurchOrderJournalPrint.parmUsePrintManagement(false);
    purchPurchOrderJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    purchPurchOrderJournalPrint.printJournal(set);
}

 
 

Print sales invoice through code

The following job demonstrates, how you can print an existing Sales invoice through code. The example sends the report to screen.

static void printSalesInvoiceThroughCode(Args _args)
{
    SalesInvoiceJournalPrint salesInvoiceJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustInvoiceJour::findRecId(5637188088));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesInvoiceJournalPrint = SalesInvoiceJournalPrint::construct();
    salesInvoiceJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesInvoiceJournalPrint.parmUsePrintManagement(false);
    salesInvoiceJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesInvoiceJournalPrint.printJournal(set);
}

 
 

Query On-Hand inventory using specific inventory-dimensions

Using the class InventDimOnhand, you can determine the on-hand inventory of articles and/or specific inventory-dimensions.

The following job determines the inventory for a specific item and a specific inventlocation. This is grouped per color.

static void getInventOnhandExample(Args _args)
{
    ItemId itemId;
    InventDimOnHand inventDimOnHand;
    InventDimParm inventDimParmOnHandLevel;
    InventDimOnHandIterator inventDimOnHandIterator;
    InventDimOnHandMember inventDimOnHandMember;
    InventDim inventDim;
    InventDim inventDimCriteria;
    InventDimParm inventDimParmCriteria;

    // Item: Query specific item
    itemId = "DMO003";
    
    // inventDimCriteria: Apply ranges
    inventDimCriteria.wmsLocationId             = "12-1";
    inventDimCriteria.InventBatchId             = "DMOBatch001";

    // inventDimParmCriteria: should values from inventDimCriteria be used?
    inventDimParmCriteria.ItemIdFlag            = false;
    inventDimParmCriteria.InventSiteIdFlag      = false;
    inventDimParmCriteria.InventLocationIdFlag  = false;
    inventDimParmCriteria.wmsLocationIdFlag     = true;     // wmsLocationId from inventDimCriteria will be used
    inventDimParmCriteria.wmsPalletIdFlag       = false;
    inventDimParmCriteria.InventBatchIdFlag     = false;    // inventBatchId from inventDimCriteria will not be used
    inventDimParmCriteria.InventSerialIdFlag    = false;
    inventDimParmCriteria.ConfigIdFlag          = false;
    inventDimParmCriteria.InventSizeIdFlag      = false;
    inventDimParmCriteria.InventColorIdFlag     = false;
    inventDimParmCriteria.InventStyleIdFlag     = false;

    // inventDimParmOnHandLevel: Which dimensions should be used to group for?
    // inventDimParmOnHandLevel necessary for inventDimOnHandLevel::DimParm
    inventDimParmOnHandLevel.ItemIdFlag            = true;      // necessary
    inventDimParmOnHandLevel.InventSiteIdFlag      = false;
    inventDimParmOnHandLevel.InventLocationIdFlag  = false;
    inventDimParmOnHandLevel.wmsLocationIdFlag     = false;
    inventDimParmOnHandLevel.wmsPalletIdFlag       = false;
    inventDimParmOnHandLevel.InventBatchIdFlag     = false;
    inventDimParmOnHandLevel.InventSerialIdFlag    = false;
    inventDimParmOnHandLevel.ConfigIdFlag          = false;
    inventDimParmOnHandLevel.InventSizeIdFlag      = false;
    inventDimParmOnHandLevel.InventColorIdFlag     = true;      // group by color
    inventDimParmOnHandLevel.InventStyleIdFlag     = false;

    inventDimOnHand = InventDimOnHand::newAvailPhysical(itemId,
                                                        inventDimCriteria,
                                                        inventDimParmCriteria,
                                                        InventDimOnHandLevel::DimParm,
                                                        inventDimParmOnHandLevel);

    inventDimOnHandIterator = inventDimOnHand.onHandIterator();
    while (inventDimOnHandIterator.more())
    {
        inventDimOnHandMember = inventDimOnHandIterator.value();

        inventDim = InventDim::find(inventDimOnHandMember.parmInventDimId());

        info(con2Str([  inventDimOnHandMember.parmItemId(),
                        inventDim.InventSiteId,
                        inventDim.InventLocationId,
                        inventDim.wmsLocationId,
                        inventDim.wmsPalletId,
                        inventDim.InventBatchId,
                        inventDim.InventSerialId,
                        inventDim.ConfigId,
                        inventDim.InventSizeId,
                        inventDim.InventColorId,
                        inventDim.InventStyleId,
                        inventDimOnHandMember.parmInventQty()]));

        inventDimOnHandIterator.next();
    }
}

The output of the above job looks is an infolog like the following:

DMO003,,,12-1,,,,,,Cherry,,54
DMO003,,,12-1,,,,,,Black,,100


 
 

Get all tables, where a particular property has a specific value

The following job lists all tables where a particular property - in the example the property ModifiedBy is requested - has a specific value.

In macro #Properties you find another possible properties of AOT objects, so you can use the job also to query other properties.

static void findTablesWithSpecificProperty(Args _args)
{
    TreeNode treeNodeTables;
    TreeNode treeNode;
    str prop;
    str properties;

    #aot
    #Properties;

    treeNodeTables = TreeNode::findNode(#TablesPath + #AOTRootPath);
    treeNodeTables = treeNodeTables.AOTfirstChild();

    while(treeNodeTables)
    {
        properties      = treeNodeTables.AOTgetProperties();
        prop = Global::findProperty(properties,#PropertyModifiedBy);

        if(prop == "yes")
        {
            info(treeNodeTables.AOTname());
        }

        treeNodeTables = treeNodeTables.AOTnextSibling();
    }
}

 
 
Pages « 1 ... 12 13 14 15 16 17 18 ... 22 » 

 

 
 
 
Posts of the actual month
April 2024
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile 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.