Skip to main content

Notifications

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.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Changing default value of check Box to "NO"

    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.

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: Changing default value of check Box to "NO"

    At form Code

    Crtl+F(SummarizeByCategory) = SourceType.modified.

    Crtl+F(SourceType.modified) =  run

  • bilal170795 Profile Picture
    185 on at
    RE: Changing default value of check Box to "NO"

    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?

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Changing default value of check Box to "NO"

    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);
    
        }
    }

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,118 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans