Update incorrect Sales order status

In case you see that the sales order header or line status is wrong you can run a script that updates the line status based on the remaining qty and the header status based on the lowest status used in the sales order lines.

static void updateSOLineStatus(Args _args)
    SalesLine       salesLine;
    SalesStatus     oldSalesStatus;

    while select forUpdate salesLine
        where salesLine.SalesStatus == SalesStatus::Backorder
        oldSalesStatus = salesLine.SalesStatus;
        if (salesLine.SalesStatus != oldSalesStatus)
            info(strfmt('SO %1 updated, from %2 to %3',salesLine.SalesId, oldSalesStatus, salesLine.SalesStatus));

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s