Import Export Model D365FO



Import Export Model D365FO





Export Model

ModelUtil.exe -export -metadatastorepath=[path of the metadata store] -modelname=[name of the model to export] -outputpath=[path of the folder where the model file should be saved]

ModelUtil.exe -export -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname="FleetManagement" -outputpath=c:\temp



Import Model

ModelUtil.exe -import -metadatastorepath=[path of the metadata store where model should be imported] -file=[full path of the file to import]

ModelUtil.exe -import -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname="FleetManagement" -outputpath=c:\temp


Important 
You can find the model name in Descriptor file in the tag of   <DisplayName> Tag



Support Faryal's Cusine


Generate class from SQL database table


Generate class from SQL database table




declare @TableName sysname = 'BANKACCOUNT'
declare @Result varchar(max) = 'public class ' + UPPER(LEFT(@TableName,1))+LOWER(SUBSTRING(@TableName,2,LEN(@TableName)))  + 'Entity

{'

select @Result = @Result + '
    public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
    select
        replace(col.name, ' ', '_') ColumnName,
        column_id ColumnId,
        case typ.name
            when 'bigint' then 'long'
            when 'binary' then 'byte[]'
            when 'bit' then 'bool'
            when 'char' then 'string'
            when 'date' then 'DateTime'
            when 'datetime' then 'DateTime'
            when 'datetime2' then 'DateTime'
            when 'datetimeoffset' then 'DateTimeOffset'
            when 'decimal' then 'decimal'
            when 'float' then 'float'
            when 'image' then 'byte[]'
            when 'int' then 'int'
            when 'money' then 'decimal'
            when 'nchar' then 'char'
            when 'ntext' then 'string'
            when 'numeric' then 'decimal'
            when 'nvarchar' then 'string'
            when 'real' then 'double'
            when 'smalldatetime' then 'DateTime'
            when 'smallint' then 'short'
            when 'smallmoney' then 'decimal'
            when 'text' then 'string'
            when 'time' then 'TimeSpan'
            when 'timestamp' then 'DateTime'
            when 'tinyint' then 'byte'
            when 'uniqueidentifier' then 'Guid'
            when 'varbinary' then 'byte[]'
            when 'varchar' then 'string'
            else 'UNKNOWN_' + typ.name
        end ColumnType,
        case
            when col.is_nullable = 1 and typ.name in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
            then '?'
            else ''
        end NullableSign
    from sys.columns col
        join sys.types typ on
            col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
    where object_id = object_id(@TableName)
) t
order by ColumnId

set @Result = @Result  + '
}'

print @Result






public class BankaccountEntity

{
    public int ID { get; set; }

    public string BANK { get; set; }

    public string ROUNTINGNUM { get; set; }

    public string CURRENCY { get; set; }

    public string ACCOUNTNUM { get; set; }

    public int? MAINACCOUNTID { get; set; }

    public string IBAN { get; set; }

    public string SWIFT { get; set; }

    public string BRANCH { get; set; }

    public string CONTACTPERSON { get; set; }

    public string CONTACTPHONE { get; set; }

    public string CONTACTEMAIL { get; set; }

    public bool? STATUS { get; set; }

}


Support Faryal's Cusine


Map Enumerator VS Map Iterator D365FO



Map Enumerator VS Map Iterator



Map Enumerator

Map enumerators are automatically created on the same tier as the map when you call the Map.getEnumerator method.

Using the MapEnumerator class avoids a potential problem in code marked as Called from, where the iterator and map can end up on separate tiers
Map enumerators require less code than map iterators, they perform slightly better.

Map Iterator

Map Iterator should be used when you want to delete items from a list by using the MapIterator.delete method.

Support Faryal's Cusine


LCS Package Deployment failed D365FO




LCS Package Deployment failed D365FO




Yesterday, I faced the error during Package deployment through LCS on newly provision Environment.

Deployment were crash on Step-24 and on Runbook the only thing is mentioned that script halted..


Runbook Step

 <Log>
      <Time>2018-08-28T07:02:12.4782433+00:00</Time>
      <MachineName>KHA-DEV-1</MachineName>
      <StepID>24</StepID>
      <Message>The step started</Message>
    </Log>
    <Log>
      <Time>2018-08-28T07:03:46.6864227+00:00</Time>
      <MachineName>KHA-DEV-1</MachineName>
      <StepID>24</StepID>
      <Message>ScriptHalted</Message>
    </Log>
    <Log>
      <Time>2018-08-28T07:03:46.6864227+00:00</Time>
      <MachineName>KHA-DEV-1</MachineName>
      <StepID>24</StepID>
      <Message>The step failed</Message>
    </Log>

When I download the detail logs of the deployment nothing was mentioned their related to Failure of the step..


When I check event viewer logs of the Instance found below error 

Faulting application name: Microsoft.Dynamics.AX.Deployment.Setup.exe, version: 7.0.4841.41289, time stamp: 0x1d43b12822ca100
Faulting module name: , version: , time stamp: 0x Please see crash analysis results at https://azurewatson.cloudapp.net
Exception code: 0x Please see crash analysis results at https://azurewatson.cloudapp.net
Fault offset: 0x Please see crash analysis results at https://azurewatson.cloudapp.net
Faulting process id: 0x1980
Faulting application start time: 0x1d43ea61e64c62f, kernel time: 0x02a05724, user time: 0x07f8dcf0
Faulting application path: K:\AosService\WebRoot\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe
Faulting module path:  Please see crash analysis results at https://azurewatson.cloudapp.net
Report Id: 7862bf9a-e223-4488-aa6d-a3b5fe340b37
Faulting package full name: 
Faulting package-relative application ID:


After spending hours of hours we decide to log the issue to Microsoft about this strange behavior..

After investigation Microsoft found that this is product issue which they are facing on newly create VM and provide solution with us..

Following is the solution provided by Microsft




The workaround for the issue is the following, and from my testing, these steps can be performed on a machine that is a non-admin developer box in Microsoft’s subscription:
  1. Go to the Environment Details page that shows the servicing status of Failed
  2. Click on the Manage Environment header if you need to expand it to see the RDP and password information
  3. RDP into your Developer/Demo or AOS machine within the environment and perform the following steps to Repair the ODBC Driver 17 installation on the machines
    1. Go to the Start menu and open Add or Remove programs
    2. In the Add or Remove Programs window, type ODBC in the Search box which should let you see the following results:
                                 

    1. Then highlight the ODBC Driver 17 and press Modify, then click Next on the opening window of the wizard
    2. Then choose Repair and press Next and then press Install on the next dialog
             


    1. Wait for the install to finish and press the Finish button
    2. Repeat these steps for every AOS machine in your environment (including any Private AOS) if you are using a multi-box Sandbox environment.
  1. After these steps have been performed on every AOS, go back to LCS and press Resume to continue with the servicing operation.
  2. If the you already aborted the operation, you can perform these actions BEFORE starting the servicing operation






Support Faryal's Cusine


VSTS Token Expire on LCS


VSTS Token Expire on LCS



From last week, LCS was showing popup to me to change VSTS access token.. I was ignoring the prompt message and was focus with my daily task..



When ever popup prompt to me i Just click No. 

After sometime due to some technical reason I have to de-allocate my Build machine. When de-allocation process complete. I face a strange behavior that configure button of instance was grayed.




After spending hours of hours over internet, I believe that issue cause because of VSTS Access token expire... So i decide to Generate token again from VSTS..

following are the simple steps to generate token over lcs.

First login on VSTS project you can find the Project URL on LCS project setting.

Then click on Team services TAB.


Copy the URL address and paste over browser. then click on security icon.



Now click on add token from personal access token TAB.



Now fill the newly open form and click on generate 



An access token will appear to you, please copy and save in notepad file for future reference. it will no longer available to you again.


Now go to project setting and click on Visual studio team services.



Click on change Button

Enter the personal access token 



Now click on continue then next and then click on save...

Now go back to check your build machine configure button, it will be enable for you..







Support Faryal's Cusine


Bar Code in SSRS Report D365FO


Bar Code in SSRS Report D365FO


Following are the simple steps to generate Bar-Code in SSRS report.

In SSRS temporary table, Bar-Code filed should be extended with BarCodeString EDT.

Use font >BC C128 Narrow

Field in SSRS should be well space otherwise bar-code scan will not work

Using following code you can generate bar-code of any value...

Example: xyzTableBuffer.BarCodeField= this.getBarcode("123456789")


    public str getBarcode(str _barCodeText)
    {
        BarcodeCode128 barcode;

        barcode = Barcode::construct(BarcodeType::Code128);
        barcode.string(true, _barCodeText);
        barcode.encode();

        return barcode.barcodeStr();
    }



Please feel free to contact me if you are facing any issue during implementation of the blog

Support Faryal's Cusine


List of Tables Method X++





List of Tables Method X++




public class SLD_MethodList
{
   

    public static void main(Args _args)
    {
   
        SysDictMethod   sysDictMethod;
        SysDictTable sysDictTable;
        Set dictMethod;
         sysDictTable = new SysDictTable(tableName2Id('CustTable'));
         dictMethod = sysDictTable.methods(true, true, true);

         SetEnumerator enumerator = dictMethod.getEnumerator();

        while (enumerator.moveNext())
        {
            sysDictMethod = enumerator.current();
           
            info(sysDictMethod.name());
        }

    }
}

Support Faryal's Cusine


Edit Method D365FO





Edit Method D365FO




In AX 2009, when reference control was not available, in the table if there is a relation created on the basis of any field i.e. there is a child table and it contains the record Id of the parent Table. When that child table binds to form, (to display and select the user-friendly information from the parent table, lookup controls were used). The record Id of the user-friendly value is saved on the table with the help of the edit methods.

Here is the example to use Edit Method.



edit int ageUpdate(boolean _set, int value)
    {
        SLD_DemoTable _demoTable;
        int  ret;

        // find the car records from the car table with update = true
        _demoTable = SLD_DemoTable::find(this.Name, _set);

        if (_set)
        {
            ttsbegin;

            _demoTable.Age = value;
            _demoTable.update();

            ttscommit;
        }
        else
        {
            ret = _demoTable.Age;
        }

        return ret;
    }

Support Faryal's Cusine


Long Processing Dialog D365FO



Long Processing Dialog  D365FO

There is a class in Dynamics 365FO Named SysOperationSandbox which is handle long running dialog for long running processes.. this class support Class and table level static method only..

Following are the Parameters 


  • Class / Table name 
  • Method Name
  • Container
  • Caption Message
  • Completion Message
  • Failure Message 

Form Code

 [Form]
public class SLD_DemoForm extends FormRun
{
    [Control("Button")]
    class FormButtonControl1
    {
        /// <summary>
        ///
        /// </summary>
        public void clicked()
        {
            container _container=["You can pass parameter to your method",1000];
            SysOperationSandbox::callStaticMethod(classNum(SLD_DemoInstance),
            staticMethodStr(SLD_DemoInstance,LongProcess),_container,
            'waiting caption should be here', 'Operation completed message should be here','Operation Cancelled should be here');
            super();
        }

    }

}



Class Code

class SLD_DemoInstance
{





    public static void LongProcess(container _container)
    {
        int contervalue= conPeek(_container,2);

        for (int i=1;i <= contervalue;i++)
        {
            /// Your logic should here
            ///
        }

    }

}






Support Faryal's Cusine


Environment hot fixes D365FO


Environment hot fixes D365FO



In my previous blogs, I have shown that how to get the list of the hotfixes applied to your environment.


Previous blog Link 


Today, I decided to create a simple page on D365FO which will show you the list of the hotfixes installed on your environment.

As we all know we can view installed hotfixes only from Visual studio and we couldn't verify the environment where Visual studio was not installed. Line UAT and production.


You can download the solution from here.

To import this project please follow this blog.


How solution work.

After successful import of the project Go to Systems Administration > Steup > Installed Hotfixes

Reference screenshot



Now click on initiate process. this process will take time.

Reference screenshot


Once the process is complete all hot fixes will be visible to you like below.

Reference screenshot




Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...