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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 558 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 402

#3
Diego Mancassola Profile Picture

Diego Mancassola 261

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans