Friday, October 9, 2020

X++ | convert string (as Datetime) to UTCdatetime

 If we got a data from the external application like "2020-10-07T11:55:27". We can use the below code to convert it to UTCdatetime.

The above format is occurred when user send a datetime field from .NET through OData (Edm.Datetime).

 class ConvertStr2UTCdatetime_Job_Test  
 {  
   public static void main(Args _args)  
   {  
     str     	 testStr = "2020-10-07T11:55:27";
     utcdatetime testUTCdateTime;  
     ;  
 
     testStr = strReplace(testStr, "T", " ");  
     testUTCdateTime = str2datetime(testStr, 321);  
     info(strFmt("testUTCdateTime %1", testUTCdateTime));  
     info('done');  
   }  
 }  


Until the next post!


Tuesday, October 6, 2020

D365FO | how to change the target Framework

In D365FO, when a project is created in Visual Studio, it is targeted to the value of "at that time" .NET Framework, for example 4.5.2 or 4.6. This can cause the following warning when building or compiling a project which has the a reference from the newer version.


Warning The primary reference "ABCXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" could not be resolved because it was built against the ".NETFramework,Version=v4.8" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6". MyXYZModel (ISV) [my XYZ Model] C:\Program Files (x86)\MSBuild\Microsoft\Dynamics\AX\Microsoft.Dynamics.Framework.Tools.BuildTasks.targets 76




Solution

I follow this useful url.

1. Unload your D365FO project.


2. Edit the rnrproj file


3. Find "TargetFrameworkVersion" tag, and change the value to your desired version.




4. Reload your project.