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

controle button depending from where the form was opened

(0) ShareShare
ReportReport
Posted on by 54
hello everyone i'm trying to controle a button that i added in SalesEditLine. 
if i open SalesEditLine from the pro forma invoice button in sales orders, i want it to be disabled.
if i opened it from the Sales Update button in SalesPostingHistory i want it to be disabled.
to do so i tried to use args.caller() but the caller is SalesFormLetter in both cases so it didn't work.
i tried to pass a parameter in the clicked method of the button so i can use it in the init method of SalesEditLine form this is the code.
[Control(/Button/)]    class ButtonUpdate    {        void clicked()        {            Args    args;            super();            str test = 'test';            args = new Args();            args.record(salesParmTable);            args.parmEnum(enum2int(DocumentStatus::Invoice));                        args.name(formstr(SalesEditLines));                        args.parm(test);            SalesFormLetter::main(args);                        salesParmTable_ds.active();        }    }
but i get this error.
any solution to this error or any other solution for the problem.
thank you for help.
I have the same question (0)
  • Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at
    Isn't the difference in that SalesPostingHistory from creates a SalesFormLetter object for an existing SalesParmTable record?
     
    Hard-coding DocumentStatus::Invoice in SalesPostingHistory is a bad idea, because this form is used for other posting types as well.
  • Community member Profile Picture
    54 on at
    thank you Martin for your answer.
    how can i use SalesFormLetter object to determine which form is the caller or which button is the caller?
  • Verified answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at
    OK, let me show you how to get the answer.
     
    When you look at what ButtonUpdate in SalesPostingHistory does, you'll see this code:
    args = new Args();
    args.record(salesParmTable);
    args.parmEnum(enum2int(documentStatus));
    
    SalesFormLetter::main(args);
    If you want to know what happens inside main(), simply go to the definition. You'll find that args.record() is set to a local variable called record, which is then passed to SalesFormLetter::constructAndInitialize(). That calls initializeFromCallerRecord(), where you're interested in the section initializing the object from SalesParmTable. Remember, that's the table I pointed out to in my previous reply. There you'll see this call: this.parmCreateFromHistory(true).
     
    That's you answer. You can use parmCreateFromHistory() method of SalesFormLetter class to determine whether the call was made from posting history.
  • Community member Profile Picture
    54 on at
    it worked, thank you Marin for your help.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans