Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Table Data does not refresh after Customized Button click

Posted on by 207

hello everyone, i need help here

I have made a button in Inventory Management > Periodic > Transfer Orders > Lines

which deletes the Inventory Transactions which is not Reserve Physical (when partial) here is the picture:

8360.x.png

I have this code to delete the Not Reserved Physical (on order):

void clicked()
{
InventTransOrigin inventTransOrigin;
InventTrans inventTrans;

ttsBegin;
{
select forUpdate inventTrans
join inventTransOrigin
where inventTrans.InventTransOrigin == inventTransOrigin.RecId
join InventTransferLine
where inventTransOrigin.InventTransId == InventTransferLine.InventTransId
&& inventTrans.StatusIssue != 4
&& InventTransferLine.TransferId == InventTransferTable.TransferId;
inventTrans.delete();
}
ttsCommit;

super();
InventTransferLine_ds.refresh();
InventTransferLine_ds.executeQuery();
}

--------

when i run this, the table becomes blank, it looks like this:

y.png

so I close and open it again, and the Table Data shows up,  and the On Order is now removed ( meaning the Delete Code Works, but the Data does not Refresh in the Table)

Now, what I need is to Refresh the Table Data of the Form after the Deleting, (the Datasource is InventTransferLine_ds)

Please help me, thanks.

*This post is locked for comments

  • XSpy Profile Picture
    XSpy 207 on at
    RE: Table Data does not refresh after Customized Button click

    Hi Bhaskar Roy!

    forupdate is important because im getting error when i didnt put it,

    so I used your code and put forupdate in there:

    void clicked()

    {

    InventTransOrigin inventTransOrigin;

    InventTrans inventTrans;

    ttsBegin;

    {

    select forupdate inventTrans

    join inventTransOrigin

    where inventTrans.InventTransOrigin == inventTransOrigin.RecId

    //join InventTransferLine

    && inventTransOrigin.InventTransId == InventTransferLine.InventTransId

    && inventTrans.StatusIssue != 4

    && InventTransferLine.TransferId == InventTransferTable.TransferId;

    if ( inventTrans)

    {

    inventTrans.delete();

    }

    }

    ttsCommit;

    super();

    InventTransferLine_ds.refresh();

    }

    and now its working! thanks!

  • XSpy Profile Picture
    XSpy 207 on at
    RE: Table Data does not refresh after Customized Button click

    hi Hariharan,

    i tried using your suggestion, but nothing happened,

    all lines are gone, but after closing and opening it again, it will be back up again.

    and the Delete Inventory is still working.

    I just can't seem to refresh the data.

  • Verified answer
    5400 Profile Picture
    5400 7,160 on at
    RE: Table Data does not refresh after Customized Button click
    Why forupdate is required.
    why are selecting InventTransferLine, it is in your scope.

    Please try with below code and check.
    void clicked() { InventTransOrigin inventTransOrigin; InventTrans inventTrans; ttsBegin; { select inventTrans join inventTransOrigin where inventTrans.InventTransOrigin == inventTransOrigin.RecId //join InventTransferLine && inventTransOrigin.InventTransId == InventTransferLine.InventTransId && inventTrans.StatusIssue != 4 && InventTransferLine.TransferId == InventTransferTable.TransferId;
    if ( inventTrans)
    { inventTrans.delete();
    } } ttsCommit; super(); InventTransferLine_ds.refresh();
    }

    Only you want to delete inventtrans, why not InventTransferLine. is there any specific reason .
  • Hariharans87 Profile Picture
    Hariharans87 4,971 on at
    RE: Table Data does not refresh after Customized Button click

    Please call the refresh after the execute query.

    InventTransferLine_ds.executeQuery();

    InventTransferLine_ds.refresh();

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans