Errors

The Date Value is not a Valid Date

Error:
'The [DATE] value is not a valid date.'

Cause:
The error occurs when NAV server and Web server have different regional settings (date format).

Symptoms:
NAV gives an error when placing an order because the requested delivery date is in the incorrect format and when filtering pending orders by order date.

Solution:

Step 1: Open the codeunit 11123308 'SC - XML/System Functions' in design mode.

Step 2: Locate the 'ConvertStringToDate' function.

Step 3: Add 3 local variables of the 'Integer' type to this function: 'YearInt', 'MonthInt' and 'DayInt'.

Step 4: Replace the function code by the following implementation:

IF StringDate <> '' THEN BEGIN
  IF EVALUATE(DateValue,StringDate) THEN
    EXIT(DateValue);
  IF EVALUATE(DateTimeValue,StringDate) THEN
    EXIT(DT2DATE(DateTimeValue));
  IF EVALUATE(MonthInt,COPYSTR(StringDate,1,2)) AND
     EVALUATE(DayInt,COPYSTR(StringDate,3,2)) AND
     EVALUATE(YearInt,COPYSTR(StringDate,5,4))
THEN
 IF EVALUATE(DateValue,FORMAT(DMY2DATE(DayInt,MonthInt,YearInt)))THEN
      EXIT(DateValue);
  ERROR(Text11123317,StringDate);
END;

Step 5: Recompile the codeunit.

Related to:
Sana Commerce - NAV Connector
Sana Commerce - SQL Provider with interfaces