Search your query

Thursday, January 26, 2023

Place various No. of Decimal for Unit Price or Purchase price value, Based on the Legal Entity


Here we are taking the example of Purchase order and we required No of decimals into 4 decimal places for Purchase price for particular Legal Entity - "USMF". Other legal entities are based EDT decimals.

Example: X++ code to display only 4 decimals for particular company:

[ExtensionOf(formStr(PurchTable))]

internal final class PurchTableTFPayrollForm_Extension

{

    [Hookable(false)]

    public void init()

    {

        FormRun callerForm;

        FormRealControl purchPriceField;

        next init();

        if (curExt() == "USMF")

        {

            purchPriceField = this.design().controlName("PurchLine_PurchPriceGrid");

            purchPriceField.noOfDecimals(4);

        }

    }

}


Wednesday, January 25, 2023

Export and Import Model file using Powershell Command

> Open Powershell as Admin

> Enter cd\

> type cd C:\AosService\PackagesLocalDirectory\bin

or

> type cd K:\AosService\PackagesLocalDirectory\bin

and then type below code for EXPORT:

C:\AosService\PackagesLocalDirectory\bin> .\ModelUtil.exe -export -metadatastorepath=C:\AosService\PackagesLocalDirectory -modelname="MyCreatedModel.axmodel" -outputpath=C:\temp\myModel 

** (myModel is new custom folder)


and type this below code for IMPORT:

K:\AosService\PackagesLocalDirectory\bin>.\ModelUtil.exe -import -metadatastorepath=K:\AOSService\PackagesLocalDirectory -file=C:\temp\myModel\MyCreatedModel.axmodel



DELETE Model File PowerShell Command:

ModelUtil.exe -delete -metadatastorepath=K:\AosService\PackagesLocalDirectory\ -modelname="MyCreatedModelExtension"

Fetch and Display Dimension Description (Name) based on Dimension Id:


Create class for display method.

[ExtensionOf(tableStr(TableNameHere!))]

final Public class TableNameHere!_Extension

{

    [SysClientCacheDataMethodAttribute(true)]

    display public static Name displayDepartmentDimensionDescription(TableNameHere! _this)

    {

        DimensionAttributeValueSetStorage   dimStorage;

        DimensionAttribute                  dimAttr;

        DimensionAttributeValue             dimAttrValue;

        Name                                dimDescription;

       

        int i;

        DictTable                   dictTable;

        Common                      common;

 

        dimStorage = DimensionAttributeValueSetStorage::find(_this.DefaultDimension);

 

        for (i= 1 ; i<= dimStorage.elements() ; i++)

        {

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")

            {

                // get attribute select here.

                select firstonly dimAttrValue

                      where dimAttrValue.RecId == dimStorage.getValueByIndex(i)

                 join dimAttr

                        where dimAttr.RecId == dimAttrValue.DimensionAttribute;

 

                if (dimAttr && dimAttrValue)

                {

                    dictTable = new DictTable(dimAttr.BackingEntityType);

                    common = dictTable.makeRecord();

 

                    if (common.TableId)

                    {

                        select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;

                        dimDescription = common.(dimAttr.NameAttribute);

                    }

                }

          

            }

        }

 

        return dimDescription;

    }

Tuesday, August 9, 2022

Deploy SSRS Reports using Powershell Command


Deploy Reports in DEV Machine:

Initial Step: Run - Powershell App in Administrator.


Note: Check the directory whether C or K for VM or Cloud Hosted Machines.


  1. Deploy All Reports - All Modules:

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

  2. Deploy Specific Module Reports:

    K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation "K:\AosService\PackagesLocalDirectory" -Module ApplicationSuite


  3. Deploy only/Specific Report in Given Module:

    K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation "K:\AosService\PackagesLocalDirectory" -Module ApplicationSuite -ReportName MyTestReport.Report

 

Thursday, September 12, 2019

Restore DB in Development Environment by using BACPAC File



> Copy the bacpac file in your development environment.

> Open Command Prompt in Administrator

> Copy the below command and paste into Command Prompt and Enter

      > cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin

> Copy the below another command and paste into Command Prompt and Enter

        > SqlPackage.exe /a:import /sf:J:\AlreadyTakenBackup.bacpac /tsn:localhost /tdn:NewTargetDB /p:CommandTimeout=2400

> You might get the message when this above command is executed successfully.

> Stop all Dynamics related services and including IIS service.

> Now Open the SQL Server and rename the AXDB database into different name and again rename the "NewTargeDB" into "AXDB" Database.



NOTE: If you are unable to find this folder : C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin then,

> Open this website and download the latest sql package: https://docs.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver15

> download above file into "TEMP" folder by selecting "Save As"

> Open Temp folder > (latest) > Sql Package folder > Select File Menu and click "Open Command Prompt As Administrator" and then paste the below code:

> SqlPackage.exe /a:import /sf:J:\AlreadyTakenBackup.bacpac /tsn:localhost /tdn:NewTargetDB /p:CommandTimeout=1200

NOTE: The above comment will be giving some error for latest SQL Package so we need to add /ttsc:true this command also in import SQL Pakage command.

For Example:

> SqlPackage.exe /a:import /sf:J:\AlreadyTakenBackup.bacpac /tsn:localhost /tdn:NewTargetDB /ttsc:true /p:CommandTimeout=1200



For EXPORT bacpac FILE:

Example Code:

> SqlPackage.exe /a:export /ssn:localhost /sdn:AxDB /tf:C:\NewDatabaseFileName.bacpac /p:CommandTimeout=1200 /p:VerifyFullTextDocumentTypesSupported=false

> That's it.


Latest Update: Year: 2025

Include DB Premium edition to avoid error when importing bacpac file.

Example:
SqlPackage.exe /a:import /sf:C:\NewDatabaseFileName.bacpac /tsn:localhost /tdn:NewTargetDB /ttsc:true /p:CommandTimeout=1200 /p:DatabaseEdition=Premium /tu:"sqladmin" /tp:"yourPassword"