Want to Validate the Code on Sales Return Form

Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
Want to Validate the Code on Sales Return Form on Function button at Copy Document menu

IF HideValidationDialog OR NOT GUIALLOWED THEN
Confirmed := TRUE
ELSE
Confirmed := CONFIRM('Is it Cancel Invoice ?',FALSE);

IF Confirmed = TRUE THEN BEGIN
"Cancel Invoice" := TRUE;
"Posting No. Series" := 'CINV SALE';
END;

IF Confirmed = FALSE THEN BEGIN
"Cancel Invoice" := FALSE;
END;


recently this code is working on Posting No Series field....


can someone help me out....?????
Thanks & Regards,
Stivan D'souza

Comments

  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    While doing the copy document, the system should check the posting date and document date if they are not same then a pop up of confirm box should appear saying that if you want to cancel the invoice (YES/NO)
    if YES then Cancel Invoice field should be check marked and Posting No series should come as 'CINV SALE'.
    IF NO then Cancel Invoice field should not be check marked.
    Thanks & Regards,
    Stivan D'souza
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Where did you check whether posting date and document date are same or not?

    I understood your requirement..

    Whaat do u mean by
    recently this code is working on Posting No Series field....

    and how can we help you?
  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    the functionality is working on Posting No Series Field
    now they want to block it and do it on Copy Document of sales return order.
    Thanks & Regards,
    Stivan D'souza
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    Below is the code i have written on PUSH of Copy Document:

    IF TODAY <> "Applies to Document date" THEN
    BEGIN
    IF HideValidationDialog OR NOT GUIALLOWED THEN
    Confirmed := TRUE
    ELSE
    Confirmed := CONFIRM('Is it Cancel Invoice ?',FALSE);

    IF Confirmed = TRUE THEN
    BEGIN
    "Cancel Invoice" := TRUE;
    MESSAGE('%1',"Cancel Invoice"); in Message its showing correct value but not showing at form level
    "Posting No. Series" := 'CINV SALE';
    MESSAGE('%1',"Posting No. Series"); in Message its showing correct value but not showing at form level
    END;
    END;
    Thanks & Regards,
    Stivan D'souza
  • DuikmeesterDuikmeester Member Posts: 304
    Not to be a douche, but why not

    IF Confirmed THEN

    and

    IF NOT Confirmed THEN

    The hair in my neck raises everytime I see Booleans used otherwise.
  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    But then too its not updating.....
    Thanks & Regards,
    Stivan D'souza
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    I suggest you to write the code in Codeunit Copy Document Mgt.
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    But then too its not updating.....

    The above suggestion given by Duikmeester is not related to your problem..

    Its regarding coding standards..
  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    Thanks Mohana......
    for the information.....
    :)
    Thanks & Regards,
    Stivan D'souza
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Not to be a douche, but why not

    IF Confirmed THEN

    and

    IF NOT Confirmed THEN

    The hair in my neck raises everytime I see Booleans used otherwise.

    :thumbsup:

    Some people just refuse to do it the Navision way.
    David Singleton
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Thanks Mohana......
    for the information.....
    :)
    Welcome :thumbsup:
  • vaprogvaprog Member Posts: 1,139
    IF TODAY <> "Applies to  Document date" THEN
    BEGIN
      IF HideValidationDialog OR NOT GUIALLOWED THEN
        Confirmed := TRUE
      ELSE
        Confirmed := CONFIRM('Is it Cancel Invoice ?',FALSE);
    
      IF Confirmed = TRUE THEN
      BEGIN
        "Cancel Invoice" := TRUE;
        MESSAGE('%1',"Cancel Invoice"); // in Message its showing correct value but not showing at form level
        "Posting No. Series" := 'CINV SALE';
        MESSAGE('%1',"Posting No. Series"); // in Message its showing correct value but not showing at form level
      END;
    END;
    
    (Code tag added by me. It's so much more easy to read code when using it.)

    Add
    CurrForm.UPDATE(TRUE);
    
    to your code to
    • Modify Rec i.e. make your changes permanent
    • tell the form to display modified data
      Remarks:
    • Your code is in a Menu Item. How do you get at it when GUIALLOWED = FALSE?
    • What does this have to do with today's date? If that first condition makes any sense at all it most likely ought to be WORKDATE instead of TODAY.
    • You should not hardcode code values. You should create a field in some setup table to hold the value of your Cancel Invoice No. Series and use that field instead.
    • Earlier on you used the following
      IF Confirmed = TRUE THEN
        ...
      IF Confirmed = FALSE THEN
        ...
      
      Do this only when you modify the condition in the first IF statement and need to consider that change in the second. Otherwise use
      IF Confirmed THEN
        ...
      ELSE
        ...
      
      It's clearer, it's shorter, it's faster, it's safer.
Sign In or Register to comment.