Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Specific record value not displaying (CASE within IF statement)?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello geeks,


We have created an 'anomaly header' table which contains the anomalies for certain temp and posted documents. Now we need to add a button to the 'anomaly list' page to display the documents which are linked to the anomaly (Display the posted document types IF exists; ELSE display the temporary document types; If none exists, display an error message)..

The case for the 'posted document type' works fine. but the case for the 'document type' doesn't display anything (doesn't show any compilation error too). Can anyone find why the case for the 'document type' doesn't function in the below code?


IF pDocPosted THEN BEGIN
  MESSAGE('After IF');
  CASE pAnomalyHeader."Posted Document Type" OF
    pAnomalyHeader."Posted Document Type"::"Sale Shipment" : BEGIN
      IF lSalesShptHeader.GET(pAnomalyHeader."Posted Document No.") THEN BEGIN 
        lPostedSalesShpt.SETRECORD(lSalesShptHeader);
        lPostedSalesShpt.RUN;
      END;
    END;
    pAnomalyHeader."Posted Document Type"::"Sale Invoice" : BEGIN
      IF lSalesInvHeader.GET(pAnomalyHeader."Posted Document No.") THEN BEGIN
        lPostedSalesInv.SETRECORD(lSalesInvHeader);
        lPostedSalesInv.RUN;
      END;
    END;
  END;

  //To add case for more posted document types ..
END ELSE BEGIN
  CASE pAnomalyHeader."Document Type" OF
    pAnomalyHeader."Document Type"::"Sales Quote" : BEGIN
      IF lSalesHeader.GET(pAnomalyHeader."Document Type", pAnomalyHeader."Document No.") THEN BEGIN
        lSalesQuote.SETRECORD(lSalesHeader);
        lSalesQuote.RUN;
      END;
    END;
    pAnomalyHeader."Document Type"::"Sales Order" : BEGIN
      IF lSalesHeader.GET(pAnomalyHeader."Document Type", pAnomalyHeader."Document No.") THEN BEGIN
        lSalesOrder.SETRECORD(lSalesHeader);
        lSalesOrder.RUN;
      END;
    END;
  END;

  //To add case for more temporary document types ..
END;

Added the blow code in the action button of the 'anomaly list' page

lAnomalyHeader.INIT;
IF lAnomalyHeader.GET("No.") THEN BEGIN
  lAnoMgt.DocumentDis(TRUE, lAnomalyHeader);
END;

Thank you in advance!

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Specific record value not displaying (CASE within IF statement)?

    The issue is SOLVED now.. I put the below modified code in the 'action button' of the list page and now it displays the posted document if exists; else it displays the temporary document.

    IF "Posted Document Type" <> 0 THEN BEGIN

     AnoMgt.DocumentDis(TRUE,Rec)

    END ELSE BEGIN

     AnoMgt.DocumentDis(FALSE,Rec)

    END;

    Thank you guys for your time to review! :)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Specific record value not displaying (CASE within IF statement)?

    Where do you set the value for pAnomalyHeader record? Can you copy that code?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Specific record value not displaying (CASE within IF statement)?

    Hello Raja,

    I have declared the parameter 'pDocPosted' with the datatype boolean. So when its true, the 'posted document type' case executes. If not true, the '(temporary) document type' case must execute right? But in my case, the first case statement executes fine. But the condition is not passing inside the "END ELSE BEGIN" .. Do you have any idea about it?

  • Raja Venkat Profile Picture
    Raja Venkat 192 on at
    RE: Specific record value not displaying (CASE within IF statement)?

    IF pDocPosted then //if pDOCPOSTED = true

    it Executes

    Else

    It Wont Execute

    Can You  PLZ  Elaborate.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans