Tuesday, 27 July 2021

AX365 X++ add a new dimension value into financial dimensions

 


      DimensionValueContract _contract = new DimensionValueContract();

        _contract.parmDimensionAttribute('Dimension name');

        _contract.parmValue('Dimension value');

        _contract.parmDescription('Dimension Description');

      

        DimensionValueService _service = new DimensionValueService();

        _service.createDimensionValue(_contract);

Tuesday, 29 June 2021

AX365 create a notification to user

  SystemNotificationDataContract notification = new SystemNotificationDataContract();

        notification.Users().value(1, curUserId());

        notification.Title("Export to Excel finished");

        notification.RuleId('ExcelStaticExport');

        notification.Message("We finished your export from the Customers page");

        notification.ExpirationDateTime(DateTimeUtil::addHours(DateTimeUtil::utcNow(), 48));

        notification.ReminderInterval(5);

    

        SystemNotificationsManager::AddNotification(notification);

Tuesday, 18 May 2021

AX 2012 X++ Consume aif web service by passing list of objects

 1- Create data contract class as below

[DataContractAttribute]

class HP_TestContract

{

    str Id;

    str Name;


[DataMemberAttribute('Id'), SysOperationDisplayOrderAttribute('1')]

public str ParamId(str _Id = Id)

{

    Id = _Id;

    return Id;

}

[DataMemberAttribute('Name'), SysOperationDisplayOrderAttribute('2')]

public str ParamName(str _Name = Name)

{

    Name = _Name;

    return Name;

}

}

2-Add an AIF service method

[SysEntryPointAttribute(true),
DataMemberAttribute("HP_TestContract"),
AifCollectionTypeAttribute("_contactList",Types::Class, classStr(HP_TestContract)),
AifCollectionTypeAttribute("return",Types::Class, classStr(HP_TestContract))]
public List HeshamList(List _contactList)
{
//_contactList = contactList;
return _contactList;
}

Tuesday, 6 April 2021

AX365 Dev machine import and Export restore a DB .bacpac file from the UAT

 Download the  Get sqlpackage .NET Core for Windows


Extract the folder and run the command prompt as an administrator, and run the below command


SqlPackage.exe /a:import /sf:D:\Hesham\SafariUATbackup.bacpac /tsn:localhost /tdn:AxDB /p:CommandTimeout=1200  /ttsc:True


Export 


SqlPackage.exe /a:export /TargetFile:H:\BiKeyDB.bacpac /SourceConnectionString:"Server=localhost;Initial Catalog=AxDB;Persist Security Info=False;User ID=sa;Password=sa;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True;Connection Timeout=1200";




Tuesday, 30 March 2021

AX 365 local Dev VM open AX from outside the network

 In case we need to access the local dev machine F&O go to the below path 


C:\Windows\System32\drivers\etc


edit the host file and add the below last line


10.0.1.120 usnconeboxax1aos.cloud.onebox.dynamics.com


the IP of the dev machine 


Enjoy DAXing

Wednesday, 3 February 2021

AX365 Deploy a package locally

 1-Create a temp folder

2-Extract the package inside the temp folder

3-open the command prompt as administrator and navigate into the temp folder and run the below scripts as below

AXUpdateInstaller.exe generate -runbookid="Safarirunbook" -topologyfile="DefaultTopologyData.xml" -servicemodelfile="DefaultServiceModelData.xml" -runbookfile="Safarirunbook-runbook.xml"


AXUpdateInstaller.exe import -runbookfile="Safarirunbook-runbook.xml"


AXUpdateInstaller.exe execute -runbookid="Safarirunbook"

in case you want to rerun a step call the below

AXUpdateInstaller.exe execute -runbookid=Safarirunbook -rerunstep=7

Tuesday, 2 February 2021

AX365/2012 X++ SQL select statement inside AX

 

  Connection      connection;

        Statement       statement;

        str             query;

        Resultset       resultSet;

        container conComm;

        ;


        // create connection object

        connection = new Connection();


        // create statement

        statement = connection.createStatement();


        // Set the SQL statement

        query = "select ACQUISITIONPRICE,BookID,BookType,Status from AssetBookMerge where AssetID = '" + strAssetId + "'";


        // assert SQL statement execute permission

        new SqlStatementExecutePermission(query).assert();


        // when the query returns result,

        // loop all results for processing

        //BP Deviation documented

        resultSet = statement.executeQuery(query);


        while(resultSet.next())

        {

            // do something with the result

            conComm =[resultSet.getString(1),resultSet.getString(2),resultSet.getString(3),resultSet.getString(4)] ;

        }


        // limit the scope of the assert call

        CodeAccessPermission::revertAssert();

        return conComm;