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

Changing default value of check Box to "NO"

(0) ShareShare
ReportReport
Posted on by 185

On ProjBudgetImport form I have to set the default value of checkbox SummarizeByCategory control to No. Since there is no data source in the form so I extended the OnInitialized and also OnInitializing both event handlers to set the default value of a checkbox to "NO" but changes are not reflecting on the form. Similarly I extended the Init method of the form and use COC but still the value of checkbox is not changing, while keeping in mind the Value property of the checkbox is set to 1. Following were my code as shown below

[FormEventHandler(formStr(ProjBudgetImport), FormEventType::Initialized)]
    public static void ProjBudgetImport_OnInitialized(xFormRun sender, FormEventArgs e)
    {
        FormCheckBoxControl CheckBox = sender.design().controlName(formControlStr(ProjBudgetImport,SummarizeByCategory)) as FormCheckBoxControl;

        CheckBox.value(enum2int(NoYes::No));
    }

Same above code I used for "OnInitializing" eventhandler it was giving error "Object reference not set to an instance."

For COC I used the following code

[ExtensionOf(Formstr(ProjBudgetImport))]
final class XYZ_ProjBudgetImportForm_Extension
{
    

    public void init()
    {
        next init();
        SummarizeByCategory.value(0);

    }
}

pastedimage1613480073793v1.png

pastedimage1613480280064v2.png

Please let me know where I am lacking, Thanks.

I have the same question (0)
  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi bilal170795,

    The value is being set in SourceType.modified. This is being called from the run method. Try doing a CoC on the run method instead and see if that works for you.

    [ExtensionOf(Formstr(ProjBudgetImport))]
    final class XYZ_ProjBudgetImportForm_Extension
    {
        public void run()
        {
            next run();
            
            SummarizeByCategory.value(false);
    
        }
    }

  • bilal170795 Profile Picture
    185 on at

    Hi Gunjan,

    Thank you so much it works, can you please guide me how you find out it is calling from the run? through deugging?

  • ergun sahin Profile Picture
    8,826 Moderator on at

    At form Code

    Crtl+F(SummarizeByCategory) = SourceType.modified.

    Crtl+F(SourceType.modified) =  run

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Bilal,

    You should search for the control and it would show you where all the value is being set for the control, as Ergun mentioned. Debugging could help as well in case the values are getting set in a class called from the form.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans