Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to change a field in a form with Segmented Entry ?

(0) ShareShare
ReportReport
Posted on by 592
Hi guys,
 
May I know how to modified field value in a form with Segmented Entry ?
My intention is with form Deferral from Sales Order (this is a Subscription Billing feature) like this :
  1. When I open Sales Order, in Order line action pane there is one button labeled /Deferrals/ and when it is open will be looks like this ->
            
 
         2.  When the /Deferred/ check box turn on, it will populated based on the default given.
 
              
           3. Issue is when it is turn off, not all the value cleared ->
 
               
 
When I take a look at the form designer, there is some field with /Segmented Entry/ ->
 
I figured this is the field in relate to the problem, however I don't know how to clear this out.
Anyone can guide me on this ?
 
Thanks in advance,
 
 
 
 
 
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    Sorry I understood your requirement wronly.
    Instead of FormStringControl use FormCheckBoxControl. Also use clicked method as register override method and see if it calls when change the value of check box.
    public void run()
        {
            Object                      formControlObject;
            FormControl                 formControl;
            FormCheckBoxControl formStringControl;
            FormReferenceGroupControl   referenceGroupControl;
            int                         i;
            
            next run();
            
            referenceGroupControl = this.design().controlName(formControlStr(SubBillDeferralTransactionDeferral, SubBillDeferralRecognitionAccount));
            for (i = 1; i <= referenceGroupControl.controlCount(); i++)
            {
                formControl = referenceGroupControl.controlNum(i);
                formStringControl = formControl as FormStringControl;
                if (formStringControl != null)
                {
                    formStringControl.registerOverrideMethod(methodStr(FormCheckBoxControl , clicked), identifierStr(resetReferenceGroupModified), element);
                }
            }
        }
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    You need to use the name of the segmented entry control. Not the yes or no check box control.
    Check the below code and see if it works.
    // <summary>
        ///
        /// </summary>
        public void run()
        {
            Object                      formControlObject;
            FormControl                 formControl;
            FormStringControl           formStringControl;
            FormReferenceGroupControl   referenceGroupControl;
            int                         i;
            
            next run();
            
            referenceGroupControl = this.design().controlName(formControlStr(SubBillDeferralTransactionDeferral, SubBillDeferralRecognitionAccount));
            for (i = 1; i <= referenceGroupControl.controlCount(); i++)
            {
                formControl = referenceGroupControl.controlNum(i);
                formStringControl = formControl as FormStringControl;
                if (formStringControl != null)
                {
                    formStringControl.registerOverrideMethod(methodStr(FormStringControl, modified), identifierStr(resetReferenceGroupModified), element);
                }
            }
        }
     
    Thanks,
    Girish S.
  • Voltes Profile Picture
    Voltes 592 on at
    How to change a field in a form with Segmented Entry ?
    Hi Girish,
     
    Isn't this class supposed to check when SubBillDeferralDeferred is turn ON or OFF ?
     
    But anyway the modified method is not allow extend, right ? any suggestion how to achieve my intention then ?
     
    Thanks,
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    Error is because the control "SubBillDeferralDeferred" has DataSource method modified which has set to hookable false. So, you can't right modified method for this control.
    Also why you are mentioning the control SubBillDeferralDeferred?
    You need to mention the control name "SubBillDeferralRecognitionAccount".
     
    Thanks,
    Girish S.
  • Voltes Profile Picture
    Voltes 592 on at
    How to change a field in a form with Segmented Entry ?
    Yeah, not sure what the error element not declared is ?
     
    Also got another problem whereby the "modified" is NOT HOOKABLE. As per my understanding, we cannot add anything (extension or event handler), is it ?
     
    Anyway, this is the screen capture with the Build error ->
     
     
    Thanks,
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    I am not sure with the error. You never used element in the code but its throwing like element is not delcared.
    Try like below code. Use element keyword to get the current cursor.
    public boolean resetReferenceGroupModified(FormStringControl _control)
        {
            SubBillDeferralTransactionLineDeferral deferral = element.SubBillDeferralTransactionLineDeferral;
            if (_control.text() == '')
            {
                if (!deferral .SubBillDeferralDeferred)
                {
                    deferral .SubBillDeferralRecognitionAccount = 0;
                }
            }
            return true;
        }
     
    Thanks,
    Girish S.
  • Voltes Profile Picture
    Voltes 592 on at
    How to change a field in a form with Segmented Entry ?
    Hi both,
     
    Thanks.
    I want to understand what is needed to make a correct COC.
    So, the intention is whenever the form displayed, the standard form will do this :
    1. Turn ON the Deferred check box, all the accounts setup in Accounts section will be filled in.
    2, Turn OFF the Deferred check box, standard "forget" to clear the Revenue Recognition account number.
     
    Which number two that I would like to "fix" it.
     
    So, by referring to the blog, I'm creating this COC:
     
    [ExtensionOf(formStr(SubBillDeferralTransactionDeferral))]
    final class MY_SubBillDeferralTransactionDeferralForm_Extension
    {
        /// <summary>
        ///
        /// </summary>
        public void run()
        {
            Object                      formControlObject;
            FormControl                 formControl;
            FormStringControl           formStringControl;
            FormReferenceGroupControl   referenceGroupControl;
            int                         i;
            
            next run();
            
            referenceGroupControl = this.design().controlName(formControlStr(SubBillDeferralTransactionDeferral, SubBillDeferralDeferred));
            for (i = 1; i <= referenceGroupControl.controlCount(); i++)
            {
                formControl = referenceGroupControl.controlNum(i);
                formStringControl = formControl as FormStringControl;
                if (formStringControl != null)
                {
                    formStringControl.registerOverrideMethod(methodStr(FormStringControl, modified), identifierStr(resetReferenceGroupModified), element);
                }
            }
        }
        public boolean resetReferenceGroupModified(FormStringControl _control)
        {
            if (_control.text() == '')
            {
                if (!SubBillDeferralTransactionLineDeferral.SubBillDeferralDeferred)
                {
                    SubBillDeferralTransactionLineDeferral.SubBillDeferralRecognitionAccount = 0;
                }
            }
            return true;
        }
        
    }
     
    This is my understanding:
    1. Variable referenceGroupControl is the variable that holds the Deferred check box account
    2. The rest inside this extension run() method, will be the same. And what I think for this statement is to "catch" the modified action.
    3. The addition function resetReferenceGroupModified, is served as the modifier of the value, so I'm added condition when "Deferred control" is not check (by using exclamation), then the other field for SubBillDeferralRecognitionAccount  would need to be zero.
     
    May I know is this correct ?
    But then again I face error "element is not declared" like below:
     
    May I know what is the error means ?
     
    Thanks in advance.
     
     
     
     
     
     
     
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    Yes, there is no event handler for run method.
    You need to write COC for run method.
    Other code in the run method remains same - Instead of super you need to have the next call as mentioned in the blog
     
    Thanks,
    Girish S.
     
  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    How to change a field in a form with Segmented Entry ?
    Hi Voltes, There is 'run' method in form as specified below. You can create CoC on run method in form extension class
     
     
    [ExtensionOf(formStr(SubBillDeferralTransactionDeferral))]
    public final class SubBillDeferralTransactionDeferral_F_Extension
    {
        public void run()
        {
            next run();
            //write your code
        }
    }
     
  • Voltes Profile Picture
    Voltes 592 on at
    How to change a field in a form with Segmented Entry ?
    Hi Girish,
     
    For CoC, may I know what function I should create the extension ?
    I'm sorry I have pretty basic only for development, as well as CoC. But if not mistaken, there is no "Run()" method, am I right to say that ?
     
    Can give some example that translate that blog into this CoC thing ?
     
    Thanks in advance.
     
     

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans