web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested answer

get data from edit method in form extension

(2) ShareShare
ReportReport
Posted on by 73
Hi
 
I created an extension to the PriceDiscAdmSearch Form. It's a checkbox. it is an edit method not bound to a datasource or table so it is a form method.
For the PriceDiscAdmSearch class I created an extension as well and added a parmMethod. This is called from the Formextension closeOK - Method (like the standard is doing it)

the standard field are working fine but the value in the class set by is always false even when I set it to true. 
 
Any ideas where this issue comes from and how to solve it?

 
I have the same question (0)
  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    get data from edit method in form extension
    You can't expect us to find a bug in code that we're never seen or where you're checking the value.
     
    Instead, use the the debugger to see where thing go wrong. For example, check if you're correctly passing the value in closeOK(). It'll tell you whether you need to look for a bug in the logic before this assignment, or this part works and you need to look at later stages.
     
     
  • Jesús García Profile Picture
    561 on at
    get data from edit method in form extension
    Hi Cu31101249-0, i would need more information about your problem cause it isnt clear:
    - is the parmMethod you say a new method or are you extending the standard method ?
    - what is this method doing in the code?
    - etc
     
  • Layan Jwei Profile Picture
    8,049 Super User 2025 Season 2 on at
    get data from edit method in form extension
    Can you please share the code with us in order to help you
  • CU31101249-0 Profile Picture
    73 on at
    get data from edit method in form extension
    Here the code from Form extension and class extension with the edit method and where I want to use it
     
    [ExtensionOf(formStr(PriceDiscAdmSearch))]
    final class PriceDiscAdmSearchForm_SWPCUSMODEL_Extension
    {
        public boolean  cemSkipNonEmptyDates;
    
    
        //BP Deviation Documented
    
        edit boolean   cemSkipNonemptyDates(
            boolean         _set,
            boolean   _cemSkipNonEmptyDates
        )
        {
            if (_set)
            {
                cemSkipNonEmptyDates = _cemSkipNonEmptyDates;
            }
    
            return cemSkipNonEmptyDates;
        }
    
     
    
        public void closeOk()
        {
    
            priceDiscAdmSearch.parmSkipNonEmptyDates(cemSkipNonEmptyDates); //SEEMS TO RUN MULTIPLE TIMES AND IS FALSE EVEN IF SET TO TRUE ON THE LAST RUNS
    
            next closeOk();
        }
    }
     
     
    [ExtensionOf(classStr(PriceDiscAdmSearch))]
    final class PriceDiscAdmSearch_SWPCUSMODEL_Extension
    {
        private  boolean                     skipNonEmptytoDates;
    
        public boolean parmSkipNonEmptyDates(boolean _skipNonEmptytoDates = skipNonEmptytoDates)
        {
            skipNonEmptytoDates = _skipNonEmptytoDates;
     
            return skipNonEmptytoDates;
        }
    
        void  run()
        {
            PriceDiscAdmTrans priceDiscAdmTransIns;
    
            if(this.parmSkipNonEmptyDates(skipNonEmptytoDates))   //HERE THE VALUE IS ALWAYS FALSE EVEN IF SET TRUE ON FORM
            {
                do some code
            }
    
            next run();
        }
     
  • Jesús García Profile Picture
    561 on at
    get data from edit method in form extension
    Maybe you have to change the next run() line to earlier position? Before "if"
  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    get data from edit method in form extension
    When you say "the value", do you mean cemSkipNonEmptyDates variable in PriceDiscAdmSearch form? If so, we can completely ignore PriceDiscAdmSearch class. It's expected that skipNonEmptytoDates is always false if you never set it to true.
     
    In PriceDiscAdmSearch form, was the value ever set to true? Debug cemSkipNonemptyDates() to verify that it's called and it sets cemSkipNonEmptyDates to true. If it does, the value must be changed back to false by some other code.
     
    Also, please tell us more about what you mean by "seems to run multiple times". Are you saying that closeOK() is called multiple times? That sounds strange. Again, the debugger can tell you more about what happened - watch out for the stack trace to understand where the method was called from.
  • CU31101249-0 Profile Picture
    73 on at
    get data from edit method in form extension
    Hi Martin
     
    The value is set to true on the form where the edit method is attached which (didn't make a screenshot).
     
    I debugged the code a hundred times. 
     
    It is true. The code is called so many times (actually I do not know why because this is a bis mysteria to me.) in the first run it is still true and then it changes to false
     
     
  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    get data from edit method in form extension
    You're saying that the value is true, but not value of which variable, where and when. So it says very little.
     
    Please tell us whether cemSkipNonEmptyDates variable is true in closeOK() when you're passing it to parmSkipNonEmptyDates(). It it is, then what you're talking about in the comment at that line (claiming that IS FALSE)?
  • CU31101249-0 Profile Picture
    73 on at
    get data from edit method in form extension
    as mentioned in my comments many times the code is called many times (seems to be normal in the extensions) in the first call it is true but turns into false in the other calls of the COC 

    the system forgets about the value during the execution 
  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    get data from edit method in form extension
    No, it's not normal that closeOk() is called many times. If you're talking cemSkipNonemptyDates() method, then it's true it may be called many times, but it's not the code I'm talking about.
     
    If it's really closeOk() that is called many times, please follow my previous advice to find what code is making these calls.
     
    For reference, this is your code and your comment in question:
    public void closeOk()
    {
        priceDiscAdmSearch.parmSkipNonEmptyDates(cemSkipNonEmptyDates); //SEEMS TO RUN MULTIPLE TIMES AND IS FALSE EVEN IF SET TO TRUE ON THE LAST RUNS
    
        next closeOk();
    }
    and I'm asking about the value of cemSkipNonEmptyDates variable.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 871

#2
André Arnaud de Calavon Profile Picture

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

#3
Sagar Suman Profile Picture

Sagar Suman 237 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans