Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to delete a record while validating transfer order quantity

(0) ShareShare
ReportReport
Posted on by 170

Hi there,

I have a requirement that when i'm creating a transfer order and when i click on add in transfer line and selected a item, location,qunaitity will be 1 by defalut and i'm not changing it  and when i clicked on save it has to validate that 1 quantity is available in the repective warehouse location if it is there it has to do normal standard functionality if it is not available it has to prompt a dialog box with YES Cancel button if i click on cancel it has to delete that line from that transfer order. I have written a code but it is not deleting the line. Kindly, please help me on achieving this requirement and i have written coc on form data source validatewrite() method of inventtransferline formdatasorce.

    public boolean validateWrite()
    {
        boolean ret = true;

        next validateWrite();

        InventTransferLine inventTransferLine = this.cursor();
        InventTable    inventTable;
        InventTransferTable inventTransferTable;
        InventDim      inventDim;
        InventDimParm  invDimParm;
        Qty            availPhys;
        DialogButton   diagbut;

        select firstonly inventTable
                where inventTable.ItemId == inventTransferLine.ItemId
            join inventDim
                where inventDim.inventDimId == inventTransferLine.InventDimId
            join inventTransferTable
                where inventTransferTable.TransferId == inventTransferLine.TransferId;

        invDimParm.initFromInventDim(InventDim::find(inventDim.inventDimId));
        availPhys = InventSum::findSum(inventTransferLine.ItemId,inventDim,invDimParm).availPhysicalCalculated();

        if(inventTransferLine.QtyTransfer == 1 && availPhys == 0)
        {
            if(inventTable.customfield1 == NoYes::Yes)
            {
                diagbut = Box::okCancel(strFmt("@PG001004",inventTable.customfieldItemNumber),DialogButton::Cancel,"@SYS117647");
                if (diagbut == DialogButton::Ok)
                {
                    inventTransferLine.ItemId = inventTable.customfieldItemNumber;
                    ret = true;
                }
                else if (diagbut == DialogButton::Cancel)
                {
                    ttsbegin;
                    inventTransferLine.doDelete();
                    ttscommit;
                    //this.research(true);
                    this.refresh();
                    ret  = false;
                }
            }
        }
        return ret;
    }

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: How to delete a record while validating transfer order quantity

    Hi, Does it even create a transfer line. I think you are trying to delete transfer order lines which is not yet created. How about preventing creation of line and throwing error that no enough quantity available.

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…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans