failure codeunit 21

Hello experts!

I have a question about an error that I get often about the posting date; NAV 2009 SP1, spanish date format dd/mm/yy

Allow posting from: 01/05/16
Allow ponting to: 30/06/16

Purchase Invoice, posting date 09/05/16

that invoice is impossible to post because of this error

Codeunti 21
CheckAllowedPostingDate(ItemJnlLine : Record "Item Journal Line")
WITH ItemJnlLine DO BEGIN
:
:
IF ("Posting Date" < AllowPostingFrom) OR ("Posting Date" > AllowPostingTo) THEN
Break on error FIELDERROR("Posting Date"
END;

I think it's a failure of NAV and I need to solve :smile: thank you for your help!

Best Answer

Answers

  • RockWithNAVRockWithNAV Member Posts: 1,139
    Hey Kanika,

    You mean to say even if you have the Posting Date in the defined range you are getting this error as 'Posting date is not in the defined range'. The Only issue for this may be the Date format I believe.
  • kanikakanika Member Posts: 247

    but in other documents with the same date no problem, it is only in the purchase invoices
  • kanikakanika Member Posts: 247
    I changed the code

    IF ("Posting Date" < AllowPostingFrom) OR ("Posting Date" > AllowPostingTo) THEN
    FIELDERROR("Posting Date",Text001)

    for this other

    dia := DATE2DMY("Posting Date",1);
    mes := DATE2DMY("Posting Date",2);
    anio := DATE2DMY("Posting Date",3);
    diafrom:=DATE2DMY(AllowPostingFrom,1);
    mesfrom:= DATE2DMY(AllowPostingFrom,2);
    aniofrom:= DATE2DMY(AllowPostingFrom,3);
    diato:=DATE2DMY(AllowPostingTo,1);
    mesto:= DATE2DMY(AllowPostingTo,2);
    anioto:= DATE2DMY(AllowPostingTo,3);
    IF ((dia<diafrom) AND (mes<mesfrom) AND (anio<aniofrom)) OR ((dia>diato) AND (mes>mesto) AND (anio>anioto)) THEN
    FIELDERROR("Posting Date",Text001);

    and it works without problem the codeunit 21, but returns this error in the codeunit 11

    RunCheck(GenJnlLine,JnlLineDim)
    WITH GenJnlLine DO BEGIN
    :
    :
    IF DateNotAllowed("Posting Date") THEN
    break in error FIELDERROR("Posting Date",Text001);
  • Developer101Developer101 Member Posts: 552
    Check in the User Setup for the user who is trying to post the invoice and check if there are Allow posting dates are defined for that user,
    United Kingdom
  • Peter+is1Peter+is1 Member Posts: 174
    Hi,

    Don't think it is a bug in NAV.
    I see 2 options (but I don't know everything):

    1) When I look at the code in NAV2009 CU21, I see it, looking up UserSetup and GLSetup.
    Where UserSetup is leading if it has data. How is your UserSetup ?

    2) A user is working in NAV on a computer with wrong country (date) settings.

    Good luck.
    \\
    The truth exists in seven versions.
  • kanikakanika Member Posts: 247
    edited 2016-06-17
    Hello,
    the User Setup and GLSetup have identical dates,
    and that user can also post other documents with that date without problem.
  • Developer101Developer101 Member Posts: 552
    That is very strange ; never face any issues before maybe because I have not dealt with other languages NAV.
    United Kingdom
  • kanikakanika Member Posts: 247
    I really think it's a bug, because when comparing day, month and year separately does not fail

    I'll do the same with the CU11
  • Peter+is1Peter+is1 Member Posts: 174
    edited 2016-06-17
    Hi Kanika,

    You are in danger here!
    IF ((dia<diafrom) AND (mes<mesfrom) AND (anio<aniofrom)) 
    OR ((dia>diato) AND (mes>mesto) AND (anio>anioto)) THEN
    

    is not the same as
    IF ("Posting Date" < AllowPostingFrom) OR ("Posting Date" > AllowPostingTo) THEN
    

    diafrom = 1 (01/05/2016) then
    for example: (dia<diafrom) is for you (day < 1) and that will never happen...
    \\
    The truth exists in seven versions.
  • KishormKishorm Member Posts: 921
    Very strange. Try changing the FIELDERROR message to a custom error message which shows you the posting date, the AllowFromDate and the AllowToDate - this should give you a bit more of a clue as to what's going on.
  • rodryrodry Member Posts: 7
    I think there is a wrong custom code somewere...
Sign In or Register to comment.