web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Warehouse Receipt Line

(0) ShareShare
ReportReport
Posted on by

I'm creating a function which when you reopen a Purchase Order it finds the Warehouse Receipt Line related to it and Once prompted can find the lines related to the purchase order and delete it. 

The current code I have for it is 


recWhseRecieptLine.RESET;
recWhseRecieptLine.SETRANGE("Source Type",recWhseRecieptLine."Source Type");
recWhseRecieptLine.SETRANGE("Source Subtype",recWhseRecieptLine."Source Subtype");
recWhseRecieptLine.SETRANGE("Source No.",recPurchHeader."No.");

IF recWhseRecieptLine.FINDSET THEN BEGIN
IF CONFIRM(Text014,FALSE) = FALSE THEN
EXIT;

recWhseRecieptLine.RESET;
recWhseRecieptLine.SETRANGE("Source Type",recWhseRecieptLine."Source Type");
recWhseRecieptLine.SETRANGE("Source Subtype",recWhseRecieptLine."Source Subtype");
recWhseRecieptLine.SETRANGE("Source No.",recPurchHeader."No.");
recWhseRecieptLine.DELETE(TRUE);
END;
END;



I am however unsure on the SETRANGE I should be using. For example Im unsure where you will find the SourceType and Source Subtype for the warehouse receipt line. 

58.PNG

As well as my setRang

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    As well as my SETRANGE below in order to find the record to delete, is that required and if so how should it be written?

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    Where are you getting the SourceType and Source Subtype? From Purchase? If yes, then you apply it, else you can give the custom filter.

    recWhseRecieptLine.RESET;

    recWhseRecieptLine.SETRANGE("Source Type",recWhseRecieptLine."Source Type"); // Where are you getting this from?

    recWhseRecieptLine.SETRANGE("Source Subtype",recWhseRecieptLine."Source Subtype"); // Where are you getting this from?

    recWhseRecieptLine.SETRANGE("Source No.",recPurchHeader."No.");

    IF recWhseRecieptLine.FINDSET THEN

    BEGIN

      IF CONFIRM(Text014,FALSE) = FALSE THEN

            EXIT

      ELSE

      BEGIN

         REPEAT

            recWhseRecieptLine.DELETE(TRUE);

         UNTIL recWhseRecieptLine.NEXT = 0

      END;

    END;

    This code would work. But dont you want to delete the Warehouse Receipt Header rather than the Lines?

    Hope it helps

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    Please read the official documentation of SETRANGE in C/AL to know more: msdn.microsoft.com/.../dd355053.aspx

  • Community Member Profile Picture
    on at

    Thank you! Yes sorry I may of wrote that wrong.

    I am looking to find the Whse Receipt Lines related to the  purchase order. Once I have found them I then need to find the Warehouse Receipt relating to those Receipt Lines and then delete the header.

  • Verified answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi Lewis,

    Can a Purchase Order contain multiple Whse Receipts or one Whse Receipt for one Purchase Order?

    If the mapping is one-to-one then you can just delete the header rather considering the lines. By deleting the header, the system will automatically delete the lines.

    For that, you can write it as,

    recWhseRecieptHEADER.RESET;

    recWhseRecieptHEADER.SETRANGE("Source No.",recPurchHeader."No.");

    IF recWhseRecieptHEADER.FIND('-') THEN

    BEGIN

     IF CONFIRM(Text014,FALSE) = FALSE THEN

           EXIT

     ELSE

     BEGIN

           recWhseReciepHEADER.DELETE(TRUE);

     END;

    END;

    Or if you wanted to delete only the line, you can use the previous code.

  • Community Member Profile Picture
    on at

    Do you know what the Source type and Source Sub type are from.

    recWhseRecieptLine.RESET;

    //recWhseRecieptLine.SETRANGE("Source Type", recWhseRecieptLine."Source Type");

    //recWhseRecieptLine.SETRANGE("Source Subtype", recWhseRecieptLine."Source Subtype");

    recWhseRecieptLine.SETRANGE("Source No.", recPurchHeader."No.");

    Using the debugger these don't appear to be finding a record but if you change the source type from 39 to anything else the warehouse receipt won't show.

    64.PNG

    64.PNG

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans