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 :
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

I have the same question (0)
  • Blue Wang Profile Picture
    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,423 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,093 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,710 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
    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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans