Search your query

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"

Tuesday, September 19, 2017

Entity Extension Events Class (DMF - Data Management)

Operations (Insert, PostLoad) on AX Entity Extension class.

> Bring the List of Datasources value from Args() by using "DataEntityDataSourceRuntimeContext"

> Identify the required Datasource by using this keyword "dataEntityDataSourceStr"

> Write the code for update/insert into particular table / related tables.


For Example:

[PreHandlerFor(tableStr(HcmWorkerEntity), tableMethodStr(HcmWorkerEntity, insertEntityDataSource))]

    public static void HcmWorkerEntity_Pre_insertEntityDataSource(XppPrePostArgs args)
    {
        DataEntityDataSourceRuntimeContext  dataSourceCtx    = args.getArg('_dataSourceCtx');

        switch (dataSourceCtx.name())
        {
            case dataEntityDataSourceStr(HcmWorkerEntity, HcmWorkerTitle):

                HcmWorkerTitle      hcmWorkerTitle = dataSourceCtx.getBuffer();
                // Write your logic..
                break;
        }
    }




Wednesday, July 12, 2017

Display methods in AX Extension Table (Dynamics 365)

Display methods in AX Extension Table (Dynamics 365)


Steps:

1. Create a class and set a name like <"TableName" and "_" and "Extension" > (Example: PurchTable_Extension)

2. Class should be a static class  and public access specifier.

3. Add this attribute  [SysClientCacheDataMethodAttribute(true)] for each display method header.

4. Display method should be a static method and public access specifier.

5. Only one parameter that should be that particular table name.

6. Go to that particular form, Create one field and set the datasource property as the above mentioned table and in datamethod property, Type like ClassName::MethodName.
(Ex: HcmWorker_Extension::dispWorkerPositionTitle)

Example X++ Code: 

//This method is used to find the Position title of current worker.//

public static class HcmWorker_Extension
{
    // BP deviation documented
    [SysClientCacheDataMethodAttribute(true)]
    public static display HcmTitleId dispWorkerPositionTitle(HcmWorker _this)
    {
        HcmPositionWorkerAssignment workerAssignment;
        HcmPosition hcmPosition;
        HcmPositionDetail hcmPositionDetail;

        select firstonly worker, Position from workerAssignment
            where workerAssignment.Worker == _this.RecId
            join recid from hcmPosition
            where hcmPosition.RecId == workerAssignment.Position
            join Title, Position from hcmPositionDetail
            where hcmPositionDetail.Position == hcmPosition.RecId;

        return HcmTitle::find(hcmPositionDetail.Title).TitleId;
    }
}


Fetch CostCenter, Department Dimensions based on Worker's Position


// Fetch CostCenter, Department Dimensions based on Worker's Position //

     public static Name workerPositionCostCenter(HcmWorker _this)
    {
        HcmPositionWorkerAssignment     workerAssignment;
        HcmPosition                     hcmPosition;
        HcmPositionDefaultDimension     hcmPositionDefaultDimension;
        DimensionAttributeValueSet      dimensionAttributeValueSet;
        DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
        OMOperatingUnit                 omOperatingUnit;

        select firstonly worker, Position from workerAssignment
            where workerAssignment.Worker == _this.RecId
            join recid from hcmPosition
            where hcmPosition.RecId == workerAssignment.Position;

        select firstonly DefaultDimension from hcmPositionDefaultDimension
            where hcmPositionDefaultDimension.Position == hcmPosition.RecId

            join RecId from dimensionAttributeValueSet
                where dimensionAttributeValueSet.RecId ==          
                hcmPositionDefaultDimension.DefaultDimension

                join DimensionAttributeValueSet, DisplayValue from dimensionAttributeValueSetItem
                    where dimensionAttributeValueSetItem.DimensionAttributeValueSet ==
                             dimensionAttributeValueSet.RecId

                    join Name from omOperatingUnit
                        where  omOperatingUnit.OMOperatingUnitNumber ==
                              dimensionAttributeValueSetItem.DisplayValue
                            && omOperatingUnit.OMOperatingUnitType   ==
                                          OMOperatingUnitType::OMCostCenter; // You can change Operating Unit Type based on your requirement.

        return omOperatingUnit.Name;
    }