Tuesday, 17 April 2018

Generate file name with time and random number X++

static str getFileName(str _fileName)
{
    str             lFileName;
    UtcDateTime     dateTime = DateTimeUtil::getSystemDateTime();
    int             randomNumber;
    str             hours = '';
    str             minutes = '';
    str             seconds = '';
    str             yyyy = '';
    str             mm = '';
    str             dd = '';

    randomNumber = 0;
    randomNumber = xGlobal::randomPositiveInt32();

    hours   = int2str(DateTimeUtil::hour(dateTime));
    minutes = int2str(DateTimeUtil::minute(dateTime));
    seconds = int2str(DateTimeUtil::second(dateTime));
    yyyy    = int2str(DateTimeUtil::year(dateTime));
    mm      = int2str(DateTimeUtil::month(dateTime));
    dd      = int2str(DateTimeUtil::day(dateTime));
   
    hours   = (strLen(hours) == 1) ? '0' + hours : hours ;
    minutes = (strLen(minutes) == 1) ? '0' + minutes : minutes ;
    seconds = (strLen(seconds) == 1) ? '0' + seconds : seconds ;
    mm      = (strLen(mm) == 1) ? '0' + mm : mm ;
    dd      = (strLen(dd) == 1) ? '0' + dd : dd ;
   
    lFileName = strFmt('%1_%2%3%4_%5%6%7_%8.xml',lFileName,yyyy,mm,dd,hours,minutes,seconds,randomNumber);
    return lFileName;

}

Monday, 16 April 2018

SSRS Web Service fix


1.1        Start SSRS Service

1.       From Server, check http://pbi04/Reports from IE
2.       If we received “This page can’t be displayed”
3.       Then Open Reporting Services Configuration Management
4.       Connect to Server – PBI04 and check Report Server is “Start”
5.       Once all Green apply then select PBI04\MSSQLSERVER to all options available to edit
6.       Go to Web Service URL option and click Report Server Web Service URLs to test
7.       If page is not open then following need to check
-                      Open Command Prompt with “Run as Administrator”
-                      Run netstat –an
-                      Check list and see which Local Address has Port 80, if too many lists then
0.0.0.0 ß all IPv4 addresses on the local machine
192.168.xx.xx ß allocated IP address, for example 192.168.29.143
127.0.0.1 ß Localhost
o        Run command: netsh http show iplisten
o        This command will only show with Port 80
-                      More likely specific IP does not have Port 80 (listen) – 192.168.42.178 & 0.0.0.0
-                      Run following to add
o        netsh http add iplisten ipaddress=192.168.42.178:80
o        netsh http add iplisten ipaddress=0.0.0.0:80

Sunday, 15 April 2018

MDM Development Setup and Configuration and Troubleshooting


MDM Development Setup and Configuration and Troubleshooting
1.       All the user account which part of MDM integration is should have been grant with following permissions,
a.       MDS Service Account in computer management
b.      Should be an LogOn user to MDS Database
c.       MDS Database user should have the membership mdm_exec and axmdm_exec permission should be checked
d.      MDS Database user should have the Owned schema are mdm,stg,mdq,dqs
e.      Users should be added to MDS site user with Super user permissions.
2.       All the MDM Database should be associated with an IIS site under Default website, so you verify the same by looking into the web config of the respective MDS IIS site where the MDS Database is configuring to connect between IIS site and MDS Database.
3.       We need to make sure that MDS IIS site is up and running and the user have enough privilege to access the same by browsing the site from IIS. Basically you can verify the permission once you open the MDS site you can see all the feature like System Administration, Integration Management and User Group Permission etc.
4.       Log on to AX machine and open the Dynamics AX Management shell and execute the following command,
a.       Syntax: Set-AXMasterDataManagementMDSSetup –MDSServerName -MDSDatabase

Eg: Set-AXMasterDataManagementMDSSetup –MDSServerName dBI04 -MDSDatabase MDS
5.       Open the Dynamics AX client and make sure that the License configuration has been enabled for the MDM in the following path,
a.       System Administration->License Configuration->Data Import and Export -> MDM
6.       In Dynamics AX client, go to Data Import and Export Menu under Master Data Management select Configure MDM with following parameters,
a.       Server : MDM Database server name Eg: DBI04
b.      Repository : MDM Database Eg: MDS
c.       Service URL : Basically you can find this under MDM IIS site-> Services-> Service.svc and click on browse. Copy the same URL and paste it here.
d.      Click on Test configuration -> If user has all permission the connection should be succeeded.
7.       In Dynamics AX client, go to Publish Entities and Click on Create schema by selecting the required entity, this will basically create the schema in MDS site with new Model and Entity and you can verify the same by looking in to the MDS site. Basically, publishing the entities required Schema permission as I have mentioned above in point 1. Once the Entity schema is created in MDS site, the InMDS checkbox will be checked in the Publish entity form.
8.       In Dynamics AX client, go to Manage Synchronous and  create new Sync group. Go to entities Only published entities will be displayed in lookup, choose the required entity and save. Go to Settings and configure the Push and Pull operation. Finally click on New Schedule and Run the Sync either by batch or normally based on the Push and Pull configuration it sync the data to MDS. Once the sync is completed we’ll get info about the record count that is synced From and To MDS site.
Configuring Customer Interface
Assumption: AOS1 and AOS2 – Customer synchronous through MDM via MDS service. Let’s say AOS1 is the Source and AOS2 is the Destination.
 





By Default, Microsoft Dynamics AX 2012 R3 system contains out of BOX MDM entities they are,
1.       Customer
2.       Vendor
3.       Product
4.       Party
5.       Employee
This section describes about How to configure the standard out of box Customer Interface Sync between two different AOS system using MDS service.
1.       Open AOS1 environment and Dynamics AX client.
2.       Click on Publish Entities under MDM section under DIXF.
3.       Select Customer entity and click on Create Schema. Basically, it requires the following schema owner for the mds_schema_user user,
a.       mdm
b.      stg
c.       mdq
d.      dqs
4.      
Once the entity is published, we’ll get info saying that the “Entity is published successfully” and you can verify the same by looking into the entity in MDS site with same entity name and Model.










5.       Click on Manage Synchronization menu and Click on New to create new Sync group.
6.       After creating Sync group, click on Entity on the respective Sync group, all the Published entities will be displayed in the lookup. Select the Customer entity in the lookup and save the same.
7.       After the selecting the entity, click on settings and select the Synchronization Type, it should Push and Pull.
8.       Open AOS2 environment and Dynamics AX client.
9.       AOS2 environment should also be configured with same MDS server where the AOS1 system is connected.
10.   Once you click on Publish entities menu, you can see that the Customer entity is already Synced with checkbox InMDS is true, it says that already Customer entity is published.
11.   Click on Manage Synchronization menu and Click on New to create new Sync group.
12.   After creating Sync group, click on Entity on the respective Sync group, all the Published entities will be displayed in the lookup. Select the Customer entity in the lookup and save the same.
13.   After the selecting the entity, click on settings and select the Synchronization Type, it should be Pull.
14.   Click on New Schedule on the Sync Group and setup the Batch JOB
15.   Go to AOS1 machine and click on New Schedule on the Sync Group and setup the Batch JOB.

Important Links for the references:

Friday, 13 April 2018

Deployment script

Deploy Modelstore with less downtime

Introduction
Everyone working with the deployment of code in AX2012 should by now be familiar with the concept of a modelstore, and the importance of making sure you move the complete modelstore from your source to your target environment.

Now the time it takes to export and import a modelstore can be several minutes. Content is being read from disk and injected into model database on the SQL Server. We also know the AOS needs to be down while the AOT is getting its modelstore updated with new content, otherwise bad and unforeseen issues will eventually happen.

In order to reduce downtime while establishing an updated application, Microsoft offers tools for us to inject the modelstore into a temporary database Schema, and when all the content has been read of the disk and injected into the SQL Server database, the last operation of moving it from the temporary Schema to "dbo" can be done in just a matter of seconds. Essentially, you can get away with just the time it takes to synchronize the Data Dictionary after the new modelstore is applied to the environment.

The steps involved are already fairly well documented on MSDN, but perhaps this little Powershell script is enough to get you going.

The Code

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import-module "C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"
 
#region Variables
 
$sourceserver = "sql2012\test"
$targetserver = "sql2012\prod"
$sourcedb = "AX2012_Test_model"
$targetdb = "AX2012_Prod_model"
$modelstorepath = "c:\Modelstores\"
 
#endregion
 
#region Work
 
$dte = get-date -format s
$dte = $dte.tostring() -replace "[:\s/]", ""
$backFileName = "$modelstorepath" + $dte + ".axmodelstore"
 
Export-AXModelStore -Server $sourceserver -Database $sourcedb -File $backFileName
Initialize-AXModelStore –Server $targetserver -Database $targetdb –SchemaName Temp
Import-AXModelStore -Server $targetserver -Database $targetdb -SchemaName Temp -File $backFileName -NoPrompt
# Only works in Console
if (!$psISE)
{
 Write-Host "Press any key to when you have stopped the AOS to continue the Import..."
 $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
 Write-Host ""
}
Import-AXModelStore -Server $targetserver -Database $targetdb -Apply Temp  -NoPrompt
Initialize-AXModelStore -Server $targetserver -Database $targetdb –Drop Temp -NoPrompt
 
"Completed!"
 
#endregion

Now all you need to do to run this code is to change the variables at the top, and save it as a ps1 file somewhere, and finally run it. I have added a "press any key"-pause just before the modelstore gets applied, so you can head over to Services and Stop the AOS before it gets applied. Finally the temporary Schema gets dropped and the only thing you need to do is to start the AOS, open a developer workspace and make sure the Data Dictionary gets synchronized.

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...