Announcements
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); } }
Please let me know where I am lacking, Thanks.
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.
At form Code
Crtl+F(SummarizeByCategory) = SourceType.modified.
Crtl+F(SourceType.modified) = run
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?
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); } }
André Arnaud de Cal...
294,118
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator