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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to change Sales Order form line detail line status in d365fo

(0) ShareShare
ReportReport
Posted on by 632

Hi Friends,

I added one customized button on sales order form action pane.

I want when i click on customized button then SALESLINE table SALESSTATUS should be change to Invoiced.

I am doing this by following code.

[ExtensionOf(FormDatasourceStr(SalesTable,SalesLine))]
final class SalesTabele_FormIBC_Extension
{

        public void displayOption(Common _record, FormRowDisplayOption _options)
    {
        SalesLine  salesline,saleslineloc;
        FormDataSource    fds = element.SalesLine_ds;
        salesline  = fds.cursor();
        SalesTable SalesTable;

        next displayOption(_record, _options);

          select SalesTable where SalesTable.SalesId == salesline.SalesId;

        if(salesline.RecId != 0)
        {
            ttsbegin;
            select forupdate saleslineloc where saleslineloc.SalesId == salesline.SalesId;
            saleslineloc.SalesStatus = SalesStatus::Invoiced;
            saleslineloc.initFromSalesTable(SalesTable);
            saleslineloc.doUpdate();
            ttscommit;
        }
    }

}

By using this i can see status is changing in table but in form line status is not changing.

Please tell me how i can change in form.

Thaks & Regards

Rahul

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Rahul,

    The Table has changed, but the form has not changed?

    Have you tried to refresh the form ? research(true).

    mohsinkhalid.com/.../

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Rahul,

    Why are you writing this code to change SalesStatus? The status should change once you invoice the order and the lines.

    You shouldn't be doing it through a job.

    Please explain your business requirement.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,099 on at

    Hi Rahul, 

    You code doesn't make any sence.

    1.DisplayOption method is used for UI manipulations, but not for data update. 

    2. Sales order status depends on quantities and if you want to change status to invoiced you need to post invoice or reduce order open quantity through delivery reminder form. Changing status from code most likely will not work as status can be drop to correct one based on quantities later. 

    d365tour.com/.../

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    I am not sure about your business requirements but what you are doing is wrong . You can not change status of sales order or lines to invoiced through button click which does direct update to the table without posting any transactions. You have to post invoice for those lines which will change the status to invoiced and post entries to subledger , ledger and reduced inventory.

  • Suggested answer
    Menekse Saygili Profile Picture
    Microsoft Employee on at

    Hi,

    There is a new feature you could use out of box. It is called "Correct sales order lines manually". For ref: docs.microsoft.com/.../purchase-order-line-data-issues

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 282 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 219

#3
Subra Profile Picture

Subra 211 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans