purchase etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
purchase etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

30 Ocak 2019 Çarşamba

AX - 2012 Send Purchase order report as email

Send Purchase order report (PurchPurchaseOrder) as mail:

    SrsReportRunController          controller = new SrsReportRunController();
    PurchPurchaseOrderContract      Contract = new PurchPurchaseOrderContract();
    SRSPrintDestinationSettings     printSettings;
    VendPurchOrderJour              orderJour;
    SrsReportEMailDataContract      emailContract = new SrsReportEMailDataContract();

   select firstonly orderJour
            order by PurchOrderDate Desc,CreatedDateTime Desc
            where orderJour.PurchId == "ST000181";

    emailContract.parmAttachmentFileFormat(SRSReportFileFormat::PDF);
    emailContract.parmSubject("Purchase Order");
    emailContract.parmTo("test@hotmail.com");
    
    
    controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));
    controller.parmShowDialog(false);
    Contract.parmRecordId(orderJour.RecId);
    controller.parmReportContract().parmRdpContract(Contract);

    printSettings = controller.parmReportContract().parmPrintSettings();
    printSettings.printMediumType(SRSPrintMediumType::Email);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    printSettings.parmEMailContract(emailContract);
    printSettings.overwriteFile(true);

    controller.runReport();

There is a disadvantage of method at upper; AX will use Outlook for send email. Alternate is below has another disadvantage; it will generate a .PDF file at disk.:


  PurchTable          purchTable;
    str                 body;
    PurchLine           purchLine;
    boolean             found;
    VendPurchOrderJour  orderJour;
    Filename            filename;
    SysMailer           mailer;
    SysEmailParameters  parameters;
      SrsReportRunController  controller = new SrsReportRunController();
    PurchPurchaseOrderContract  contract = new PurchPurchaseOrderContract();
SRSPrintDestinationSettings printSettings;    
    
    controller.parmReportName(ssrsReportStr(PurchPurchaseOrder,Report));
    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
printSettings = controller.parmReportContract().parmPrintSettings();
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.overwriteFile(true);


printSettings.fileName(@filename);
    filename = strFmt(@"%1%2.PDF",WinAPI::getTempPath(),"PO00001");

     select firstonly orderJour
            order by PurchOrderDate Desc,CreatedDateTime Desc
            where orderJour.PurchId == "PO00001"
    contract.parmRecordId(orderJour.RecId);
    controller.parmReportContract().parmRdpContract(contract);
    
    controller.parmShowDialog(false);
    controller.runReport();
    infolog.clear();
    
    new InteropPermission(InteropKind::ComInterop).assert();
    mailer = new SysMailer();
    parameters = SysEmailParameters::find();


    if (parameters.SMTPRelayServerName)
    {
        mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
    else
    {
        mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
       
    body = strFmt(@"<br><caption>%1</caption><br><br>","Purchase order form is appended.");      
    
    mailer.fromAddress("sender@hotmail.com");
    mailer.tos().appendAddress("test@hotmail.com");
    mailer.htmlBody(body);
    mailer.subject(title);
    mailer.attachments().add(filename);
   
    mailer.sendMail();

3 Ocak 2014 Cuma

AXAPTA - Merge more than one purchaseses selected lines and show at PurchEditLines form

    Args                    args = new Args();
    PurchFormLetter         purchFormLetter;
    purchTable              purchTable;
    VendReceiptsListTrans   ListTrans;
    PurchParmLine           purchParmLine;
    PurchParmTable          purchParmTable;
    Object                  dialog;
    vendReceiptsListJour    Jour;
    boolean                 err;
    VendPackingSlipTrans    PackingTrans;
    ;
    select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
    //-------------- prepare purchformletter class -----
    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
    purchFormLetter.parmSourceTable(purchTable);
    purchFormLetter.initLinesQuery();
    purchformletter.createParmUpdate();
    purchFormLetter.transDate(this.PackingSlipDate);
//    purchformletter.documentNum(
    purchformletter.chooseLines();
    //--------------- add other purchtable records -----
    while select OrigpurchId from ListTrans
        group by ListTrans.OrigPurchId
        where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
    {
       select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
        purchformletter.updateQueryAndChooseLines(purchTable);
    }
    //---------------- delete unnecessary purchase lines --------------------
    select firstonly forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId();
    if (purchParmLine.RecId == 0)
    {
        box::stop("There isn't any purchline applicable");
        return;
    }
//    box::warning("111");
    ttsbegin;
    while select forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId()
    {
        select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
                ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
       // info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
        //---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
        if (ListTrans.RecId == 0)
        {
//            info("---sil---");
            purchParmLine.delete();
            continue;
        }
       //----miktarı giriş listesinden al----------------------------------
            purchParmLine.ReceiveNow = ListTrans.PurchQty;
            purchParmLine.InventNow  = ListTrans.PurchQty;
//            purchParmLine.modifiedReceiveNow();
            purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
            purchParmLine.setLineAmount();
            purchParmLine.update();
     }
    update_recordset purchParmTable setting num = this.packingSlipId,
                                            TransDate = this.PackingSlipDate,
                                            DocumentDate = this.PackingSlipDate
    where purchParmTable.ParmId == purchformletter.parmId();
    ttscommit;
    if (this.packingSlipId)
        purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
    dialog = purchformletter.dialog();
    dialog.run() ;
    dialog.wait();
    if (dialog.closedOk())
    {
            purchFormLetter.proforma(false);
            purchFormLetter.printFormLetter(true);
            purchFormLetter.specQty(PurchUpdate::ReceiveNow);
            purchFormLetter.progressHide();
            purchformletter.run();
            select firstonly PackingTrans join ListTrans
                where PackingTrans.purchId == ListTrans.OrigPurchId &&
                    ListTrans.ReceiptsListId == this.ReceiptsListId;
        if (PackingTrans.RecId != 0)
        {
            ttsbegin;
            update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
                where Jour.RecId == this.RecId;
            ttscommit;
        }
    }