Import - Export Model Dynamic AX 2012

 Import - Export Model Dynamic AX 2012


Song Nghia - Technical Consultant

1. Create model

AOT ->Tool->Model management->Create new model
2. Export model to .axmodel file:

Dung window power shell hoac dung Microsoft Dynamics AX pewer shell.
2.1 chuyen den thu muc cai dat cua file config.

EX: C:\Program Files\Microsoft Dynamics AX\60\Server\vtv_vn_dax63_cu12_hrp_staging
Cu phap: cd “C:\Program Files\Microsoft Dynamics
AX\60\Server\vtv_vn_dax63_cu12_hrp_staging”.

2.2 chay chuc nang Export cua Axutil.exe thanh file MyFile.axmodel.
Cu phap: “PS C:\Program Files\Microsoft Dynamics
AX\60\Server\vtv_vn_dax63_cu11_std_demo\bin> axutil.exe export /file:E:\USER.axmodel
/model:"SYP Labels"
(maybe ./axutil.exe)

3. Import model from .axmodel file:

Dung window power shell hoac dung Microsoft Dynamics AX pewer shell.

3.1: chuyen den thu muc cai dat cua file config.
EX: C:\Program Files\Microsoft Dynamics AX\60\Server\vtv_vn_dax63_cu12_hrp_staging
Cu phap: cd “C:\Program Files\Microsoft Dynamics
AX\60\Server\vtv_vn_dax63_cu12_hrp_staging”.

3.2 chay chuc nang Import cua Axutil.exe from file MyFile.axmodel.
Cu phap: “PS C:\Program Files\Microsoft Dynamics
AX\60\Server\vtv_vn_dax63_cu11_std_demo\bin> axutil.exe import /file:E:USER.axmodel /Verbose”

See document: 


Configuring Microsoft Dynamics AX 2012 Alerts and Email

 Configuring Microsoft Dynamics AX 2012 Alerts and Email Notifications
Using an SMTP Email Relay Server with Office 365

Song Nghia - Technical Consultant

With more AX Server machines being run in the cloud on Microsoft Azure we need a simple way to
connect Dynamics AX 2012 to cloud hosted mail servers without the need to run Exchange server in
the same Azure virtual network (vnet) as our Dynamics AX servers. Currently the demo images that
Microsoft provides for download all rely on a dedicated VM (AX2012R2B) running Exchange Server to send email alerts and workflow messages. This is not a practical or a realistic current scenario with
Dynamics AX servers running on Microsoft Azure. The Life Cycle Services demo image that gets
generated does not even include a mail server image to distribute notification emails. Today with
more clients running with Office 365 we need a way to connect our hosted AX servers to a cloud
hosted email service.
The challenge is that most cloud based email services running today require SSL or TLS secure
encryption for authentication and unfortunately Dynamics AX 2012 does not support this additional
authentication natively. There are a number of ways to customize Dynamics AX to support this
additional secure authentication but it is much easier to use a Windows Server Simple Mail Transfer
Protocol (SMTP) server as a relay. There are no additional costs to run an SMTP server as this is a
feature included in Windows Server. This article will walk through the steps to configure the
Windows Server 2012 R2 SMTP Feature to act as a relay to Office 365 as well as how to configure
Dynamics AX mail settings to support this scenario.
First consider where to install the SMTP service in your production environment. If you are using
Workflow extensively you will have at least one dedicated workflow batch server. Depending on the
volume of messages consider placing the SMTP service on this dedicated workflow batch server.
Avoid installing the SMTP service on the production database server as a best practice. However for
demo systems it works fine to include the SMTP service on the all in one server machine. For this
article we will configure the SMTP service on a Dynamics AX2012 R3-CU8 demo image generated
from Life Cycle Services.
This article only covers email alert and workflow messages. Microsoft also now has integration with
Exchange Server either on premise or on Office 365 for the Sales and Marketing module for
Account/Contacts, tasks and calendar. This integration is available but not in the scope of this article.
One more note about flooding SMTP messages from your server to the mail provider. You want to
avoid any extremely large volumes of relay messages so you don’t get blacklisted. Just keep this in
mind to avoid this situation.
We will cover the following topics throughout this article:
 Installing the SMTP Server
 Configuring the SMTP Server
o Testing SMTP Relay Messages
o Troubleshooting SMTP eMail Sending
 Configuring Dynamics AX to use Windows SMTP Server
 Configuring Alert eMail Messages
 Testing Alert eMail Messages
 Using Gmail as an SMTP Mail Server

Full document:




SrsReportRunPrinter Sent email with template

 SrsReportRunPrinter Sent email with template

Nghia Song - Technical Consultant

/// 
/// extesion of SrsReportRunPrinter
/// 
[ExtensionOf(classStr(SrsReportRunPrinter))]
final class LAW_SrsReportRunPrinter_C_Extension
{
    public SrsReportDataContract  dataContract;
    public PurchPurchaseOrderContract   purchPOContract; 
      

    public str buildEmalBody(PurchId _purchID)
    {
        PurchTable      purchTable = PurchTable::find(_purchID);
        PurchTotals     purchTotals;
        str             emailHeader,emailBody;

        purchTotals     = PurchTotals::newPurchTable(purchTable);
        purchTotals.calc();
        real            totalAmount = purchTotals.purchTotalAmount();
        emailHeader = strFmt('

Dear %1,

',purchTable.vendorName()); emailHeader += '

Good Day.

 

Please see attached P.O. for items to be delivered based on the Shipment date.

'; emailBody += strFmt('',_purchID, totalAmount,purchTable.DeliveryDate,InventLocation::find(purchTable.InventLocationId).Name); return emailHeader + emailBody; } /// /// extens to update Purchase Id incase of docoment called from PurchPurchaseOrderContract rdp /// public void printReport() { RecId recordId; SysIMailerNonInteractive mailerFail; PurchId purchId; Object objRdp = this.reportContract.parmRdpContract(); str emailBody; if (objRdp is PurchPurchaseOrderContract) { purchPOContract = objRdp; recordId = purchPOContract.parmRecordId(); purchId = VendPurchOrderJour::findRecId(recordId).PurchId; emailBody = this.buildEmalBody(purchId); printSettings.parmEMailBody(emailBody); } next printReport(); if (mailer && mailer.emailId) { if (recordId && purchId) { SysOutgoingEmailTable outEmail = SysOutgoingEmailTable::find(mailer.emailId,true); if (outEmail) { outEmail.LawPurchId = purchId; ttsbegin; outEmail.update(); ttscommit; } if (outEmail.Status == SysEmailStatus::Failed) { str toAddress = SrsReportRunMailer::lawBuildUserEmailAddress(PurchTable::find(purchId).CreatedBy); str fromAddress = outEmail.Sender; str mess = strFmt("@LAW:LAW_G02010107_01",purchId); mailerFail = SysMailerFactory::getNonInteractiveMailer(); //send fail email back to sender var messageBuilder = new SysMailerMessageBuilder(); messageBuilder.setFrom(fromAddress) .addTo(toAddress) .addCc("") .setSubject(mess) .setBody(""); boolean result = mailerFail.sendNonInteractive(messageBuilder.getMessage()); //end } } } } }
Store name/WH nameP.O.#P.O. AmountShipment/Delivery Date:
%4%1%2%3
Data elements that aren't copied during refresh

 Data elements that aren't copied during refresh

Song Nghia - Technical Consultant

When refreshing a production environment to a sandbox environment, or a sandbox environment to another sandbox environment, there are certain elements of the database that are not copied over to the target environment. These elements include:

  • Email addresses in the LogisticsElectronicAddress table.
  • Batch job history in the BatchJobHistory, BatchHistory, and BatchConstraintHistory tables.
  • SMTP Relay server in the SysEmailParameters table.
  • Print Management settings in the PrintMgmtSettings and PrintMgmtDocInstance tables.
  • Environment-specific records in the SysServerConfig, SysServerSessions, SysCorpNetPrinters, SysClientSessions, BatchServerConfig, and BatchServerGroup tables.
  • Document attachments in the DocuValue table. These attachments include any Microsoft Office templates that were overwritten in the source environment.
  • All users except the admin will be set to Disabled status.
  • All batch jobs are set to Withhold status.
  • All users will have their partition value reset to the "initial" partition record ID.
  • All Microsoft-encrypted fields will be cleared, because they can't be decrypted on a different database server. An example is the Password field in the SysEmailSMTPPassword table.
link: https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/database/database-refresh

Power shell deploy all SSRS report d365 FO

 Power shell deploy all SSRS report d365 FO

Nghia Song - Technical Consultant


Follow steps:

1) Open run prompt and type services.msc

2) Make sure IIS , Batch , DIXF , SSRS  , MR services are running.

3) Open Windows Powershell as Administrator

4) Type the below command :-

         K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”

To Deploy specific reports type the below command :-

K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -Module ApplicationSuite -ReportName AssetDep*,TaxVatRegister.Report -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”




Events from the MPOS D365 Retail/ AX 2012 R3 can be found in Event Viewer here:

Events from the MPOS D365 Retail/ AX 2012 R3 can be found in Event Viewer



Song Nghia - Technical Consultant


This post is based on a conversation in Dynamics AX Community 

1. Events from the MPOS in AX 2012 R3 can be found in Event Viewer here:

    Application and Services Logs -> Microsoft -> Windows -> AppHost -> AppTracing.

activate the event log using Event Viewer.

Navigate to Application and Services Logs -> Microsoft -> Windows -> AppHost.
Right click AppHost and Select View -> Show Analytic and Debug Logs

2. Events from the MPOS in AX 7 / Dynamics 365 for Operations can be found in Event Viewer here:

Event Viewer:
    Applications and Services Logs->Microsoft->Dynamics->Commerce-ModernPos.- Admin, Debug, Operational (where Operational would contain errors and Debug is by default disabled but can be Enabled if needed.)

Please visit the source of this post at this link

https://community.dynamics.com/ax/f/33/p/191059/490711#490711


Sample create entity POS d365 typescript

 Sample create entity POS d365 typescript 
Song Nghia - Technical Consultant



export interface ISelectDate {
    Month: Months;
    Date: number;
    Year: number;
    ToMonth: Months;
    ToDate: number;
    ToYear: number;
}

export interface IAvailableMonth {
    month: Months;
    displayText: string;
}

export enum Months {
    January = 1,
    February = 2,
    March = 3,
    April = 4,
    May = 5,
    June = 6,
    July = 7,
    August = 8,
    September = 9,
    October = 10,
    November = 11,
    December = 12
}

PrePrintReceiptCopyTrigger POS 365

 PrePrintReceiptCopyTrigger POS 365



Song Nghia - Technical Consultant


import * as Triggers from "PosApi/Extend/Triggers/PrintingTriggers";
import { ClientEntities, ProxyEntities } from "PosApi/Entities";
import { ObjectExtensions } from "PosApi/TypeExtensions";
//import ReprintReceiptCache from "../ViewExtensions/ShowJournal/ReprintReceiptCache";
//import { Entities, XZReportDocument } from "../DataService/DataServiceRequests.g";
import { GetHardwareProfileClientRequest, GetHardwareProfileClientResponse } from "PosApi/Consume/Device";
import { GetReceiptsClientRequest, GetReceiptsClientResponse } from "PosApi/Consume/SalesOrders";
import { PrinterPrintRequest, PrinterPrintResponse } from "PosApi/Consume/Peripherals";

export default class PrePrintReceiptCopyTrigger extends Triggers.PrePrintReceiptCopyTrigger {

    public execute(options: Triggers.IPrePrintReceiptCopyTriggerOptions): Promise {

        if (ObjectExtensions.isNullOrUndefined(options)) {

            // This will never happen, but is included to demonstrate how to return a rejected promise when validation fails.
            //ABC
            let error: ClientEntities.ExtensionError
                = new ClientEntities.ExtensionError("The options provided to the PrePrintReceiptCopyTrigger were invalid.");
            return Promise.reject(error);
        } else {
            return this.context.runtime.executeAsync(new GetHardwareProfileClientRequest())
                .then((response: ClientEntities.ICancelableDataResult)
                    : Promise> => {
                    let hardwareProfile: ProxyEntities.HardwareProfile = response.data.result;
                    // Gets the receipts.
                    let salesOrderId: string = options.salesOrder.Id;
                    let receiptRetrievalCriteria: ProxyEntities.ReceiptRetrievalCriteria = {
                        IsCopy: false,
                        IsRemoteTransaction: false,
                        IsPreview: false,
                        QueryBySalesId: true,
                        ReceiptTypeValue: ProxyEntities.ReceiptType.CustomReceipt6,
                        HardwareProfileId: hardwareProfile.ProfileId
                    };
                    let getReceiptsClientRequest: GetReceiptsClientRequest =
                        new GetReceiptsClientRequest(salesOrderId, receiptRetrievalCriteria);
                    return this.context.runtime.executeAsync(getReceiptsClientRequest);
                })
                .then((response: ClientEntities.ICancelableDataResult)
                    : Promise> => {
                    let receipts: ProxyEntities.Receipt[] = response.data.result;
                    // Prints the receipts.
                    let printerPrintRequest: PrinterPrintRequest = new PrinterPrintRequest(receipts);
                    return this.context.runtime.executeAsync(printerPrintRequest);
                })
        }
}