Microsoft Nav 2018 CRM connector date conversion bug

If you’re using the Nav to Microsoft CRM connetor you can have a date transmission error with message about DMY2Date paramter out of range.

I found out a function used in codeunit 5302 Outlook Synch. Type Conv called “TextToDate” handling conversion in MM/DD/AAAA format. The connector send to this function a FORMAT(Variant) so it can throw error depending on the system regional settings…

To Handle this error simply go to codeunit 5336 Integration Record Synch. In function “TransferFieldData” replace the last line with following to force date format expression :

// OnTransferFieldData is an event for handling an exceptional mapping that is not implemented by integration records
OnTransferFieldData(SourceFieldRef,DestinationFieldRef,NewValue,IsValueFound,NeedsConversion);
IF IsValueFound THEN BEGIN
  IF NOT NeedsConversion THEN
    EXIT(SetDestinationValue(DestinationFieldRef,NewValue,ValidateDestinationField));
END ELSE
  NewValue := SourceFieldRef.VALUE;

IF NOT NeedsConversion AND
   (SourceFieldRef.TYPE = DestinationFieldRef.TYPE) AND (DestinationFieldRef.LENGTH >= SourceFieldRef.LENGTH)
THEN
  EXIT(SetDestinationValue(DestinationFieldRef,SourceFieldRef.VALUE,ValidateDestinationField));

//>>NAVCRAFT Microsoft BUG - Codeunit Outlook Synch. Type Conv - Handle only MM/DD/AAAA date format
IF NewValue.ISDATE THEN
  EXIT(OutlookSynchTypeConv.EvaluateTextToFieldRef(FORMAT(NewValue, 0, '<Month>/<Day>/<Year4>'),DestinationFieldRef,ValidateDestinationField))
ELSE IF NewValue.ISDATETIME THEN
  EXIT(OutlookSynchTypeConv.EvaluateTextToFieldRef(FORMAT(NewValue, 0, '<Month>/<Day>/<Year4> <Hours24>:<Minutes,2>:<Seconds,2>'),DestinationFieldRef,ValidateDestinationField))
ELSE //<<NAVCRAFT
 EXIT(OutlookSynchTypeConv.EvaluateTextToFieldRef(FORMAT(NewValue),DestinationFieldRef,ValidateDestinationField));

Leave a Reply

Your e-mail address will not be published. Required fields are marked *