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, ...
Unanswered

On sales confirm button in SalesTable form written the logic before next but not working in D365FO

(0) ShareShare
ReportReport
Posted on by 113

Hello ,
I have written a logic on sales confirm button in SalesTable form  before next but logic is executing after run method.

Can you suggest

I have the same question (0)
  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Harish, Can you share your code and the run method that you are referring.

  • HARISH MEHRA Profile Picture
    113 on at

    [ExtensionOf(classStr(SalesFormLetter))]
    public final class SalesFormLetter_CAP_Extension
    {
        public void  run()
        {
            SalesLine      salesLine ;
            ReasonMain_CAP reason_Cap;
            PriceChangeHistory_CAP priceChangeHistory;
            Dialog dialog;
            Dialog dlg = new Dialog('@CAP:DialogCaptionInDialogSalesPrice');
            DialogField dfReasonCode = dlg.addField(extendedTypeStr(ReasonCode_CAP),'ReasonCode');
            FormBuildCommandButtonControl   OkButton;
            OkButton = dlg.formBuildDesign().control( 'OkButton');
            //Disable the Cancel button
           
            if (salesLine.orig().SalesPrice != 0)
            {
                if(dlg.run())
                if (dfReasonCode.value() != '' )
                {
                    ttsbegin;
                    dlg.closedOk();
                    priceChangeHistory.ReasonCode = dfReasonCode.value();
                    priceChangeHistory.CurrencyCode = salesLine.CurrencyCode;
                    priceChangeHistory.OrderNumber = salesLine.SalesId;
                    priceChangeHistory.ItemNumber = salesLine.ItemId;
                    priceChangeHistory.LineNum = salesLine.LineNum;
                    priceChangeHistory.OriginalPrice = salesLine.orig().SalesPrice;
                    priceChangeHistory.UpdatedPrice = salesLine.SalesPrice;
                    priceChangeHistory.ReferenceType = '@CAP:SalesOrder';
                    priceChangeHistory.CreateDateTime = today();
                    priceChangeHistory.RecIDSales = salesLine.RecId;
                    priceChangeHistory.TableIDSales = salesLine.TableId;
                    priceChangeHistory.RecIDPriceChange = priceChangeHistory.RecIDPriceChange   1 ;
                    priceChangeHistory.CreateBy =  curUserId();
                    priceChangeHistory.insert();
                    ttscommit;
                }
                else
                {
                    salesLine.SalesPrice = salesLine.orig().SalesPrice;
                    Error('Please fill the reason code');
                }
            }
          
                next run(); 
            
    
        }
    }

    Hi Mohit,

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Mohit,

    I need that my dialog window should open before the standard run method call.

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 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans