Skip to main content

Notifications

Announcements

No record found.

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.
  • Community member Profile Picture
    Community member 54 on at
    controle button depending from where the form was opened
    it worked, thank you Marin for your help.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    controle button depending from where the form was opened
    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
    Community member 54 on at
    controle button depending from where the form was opened
    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?
  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    controle button depending from where the form was opened
    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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans