Hello,
Below code sample will help to clear value of all the controls in form. Code tested in D365FO X++.
void clearFormControls(Object o)
{
FormBuildControl formBuildControl;
FormStringControl formStringControl;
FormInt64Control formInt64Control ;
FormIntControl formIntControl ;
FormRealControl formRealControl;
FormTimeControl formTimeControl;
FormCheckBoxControl formCheckBoxControl;
FormDateControl formDateControl;
Date emptyDate;
int i;
;
for (i=1;i<=o.controlCount(); i++)
{
formBuildControl = o.controlNum(i);
switch (ClassId2Name(classIdGet( element.control(formBuildControl.id()))))
{
case 'FormStringControl':
formStringControl = element.control(formBuildControl.id());
formStringControl.text('');
break;
case 'FormIntControl':
formIntControl = element.control(formBuildControl.id());
formIntControl.value(0);
break;
case 'FormInt64Control':
formInt64Control = element.control(formBuildControl.id());
formInt64Control.value(0);
break;
case 'FormRealControl':
formRealControl = element.control(formBuildControl.id());
formRealControl.realValue(0);
break;
case 'FormTimeControl':
formTimeControl = element.control(formBuildControl.id());
formTimeControl.value(0);
break;
case 'FormCheckBoxControl':
formCheckBoxControl = element.control(formBuildControl.id());
formCheckBoxControl.value(0);
break;
case 'FormDateControl':
formDateControl = element.control(formBuildControl.id());
formDateControl.dateValue(emptyDate);
break;
}
if (formBuildControl.isContainer())
clearFormControls(formBuildControl);
}
}
No comments:
Post a Comment