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.




Monday, July 20, 2020

D365FO | C# | show the current session username

This might be useful when developing something relevant to Web API. Sometimes we might need to know what is the current session running.

This can be done the below C# code.

 string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;  

Result: You can see what the exact current session is running. Something like this. 



Until the next post!


Wednesday, June 24, 2020

D365FO | OData - How to filter on Enum Properties

Problem

You are querying the data from D365FO via OData and try something as follows.

 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq 'Yes'   
 or  
 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq True   

Then you got the error.

 <Message>An error has occurred.</Message>  
 <ExceptionMessage>A binary operator with incompatible types was detected. Found operand types 'Microsoft.Dynamics.DataEntities.NoYes' and 'Edm.Boolean' for operator kind 'Equal'.</ExceptionMessage>  
 <ExceptionType>Microsoft.OData.Core.ODataException</ExceptionType>  

Many thanks to..
 


Solution

 https://aaaaaa.sandbox.ax.dynamics.com/data/PartyLocationPostalAddressesV2?$top=100&$filter=IsPrimary eq Microsoft.Dynamics.DataEntities.NoYes'Yes'  

Until the next post!




Monday, May 18, 2020

D365FO - move elements across Dev environments

Hi, moving Dev elements is different when comparing D365FO and AX 2012. 

I was inspired by this link AX7 Move specific elements from one model to another. Check it to see more interesting details.

So, you need these procedures if you are moving "a part" of projects or models. Or exchange something across many Dev box (Onebox).

Let's see how to do it.

1. For example, you would like to move these new added security objects.




2. You will find that both source and destination server had already the folder structure for those artifacts.



3. Therefore, you can copy those artifacts XML files from source to destination by operating system.



4. Finally, you can use application explorer in VS to move those artifacts to your desired project.





Thanks for reading and until the next post!