Hello everyone, I have a custom field from a purchTable form extension. This one has the self-declaration set to "no". so I wanted to change it from code, but when doing so, it gives me an error that the control was not in control inside the form.
What am I doing wrong and why can't I log in?
This is the control that I must modify the enabled property with declaration in "no", this cannot be passed to autodeclaration "yes"
For this I try to modify the enabled property with code.
[FormDataFieldEventHandler(formDataFieldStr(PurchTable, PurchLine, TaxItemGroup), FormDataFieldEventType::Modified)] public static void TaxItemGroup_OnModified(FormDataObject sender, FormDataFieldEventArgs e) { FormDataSource purchLine_ds = sender.datasource(); FormRun form = purchLine_ds.formRun(); FormControl NXRLATCLIVANoRec = form.design().controlName(formControlStr(PurchTable, NXRLATCLIVANoRecCodigo)); }
thanks for you answer
Hi Angel,
Try setting the property using object method of DataSource.
[FormDataFieldEventHandler(formDataFieldStr(PurchTable, PurchLine, TaxItemGroup), FormDataFieldEventType::Modified)] public static void TaxItemGroup_OnModified(FormDataObject sender, FormDataFieldEventArgs e) { FormDataSource purchLine_ds = sender.datasource(); FormRun form = purchLine_ds.formRun(); purchLine_ds.object(fieldnum(Tablename, fieldname)).allowEdit(false); //FormControl NXRLATCLIVANoRec = form.design().controlName(formControlStr(PurchTable, NXRLATCLIVANoRecCodigo)); }
If the enabled property of the field group was set to be yes, then you need to create new group and make the existing group visibility to No.
If you want the custom field must be inside the field group then you need to create new group and set the visiblity to No on the existing group.
Thanks,
Girish S.
Hi Angel, I think even if you can access this field in code, it will still remain disabled as this field is in a Field Group. if field group is disabled, field inside it cannot be enabled.
If you want to make it editable, remove field from field group and add next to this group, you won't need to access it from code.
Oh ok!
To get you right, the custom field in question wasn't created in your current model.
I do not think, you can modify the autodeclaration property by code.
Have you tried something like this?
NXRLATCLIVANoRecCodigo.visible().
By the wasy, check this and see if it works for you
Yes, the purchtable was extended in my model, however, I can't modify the autodeclaration because it appears disabled
The own control that I want to access was added from the fieldGroup of the table to which the datasource refers. so it was not modified directly from the form, but through the purchline table
Hi Angel,
When you say custom, it means it was created by a developer, and it is not a standard extension by Microsoft so you should have the right to modify it unless you are trying it in the wrong project.
Based on your screenshot, It seems the PurchTable from on your environment was extended in the Nexer model.
Please confirm my assumption. Could you also tell us the model in your project ?
Thanks for your answer, the field is custom, but it was updated due to a modification in a fieldGrup of the PurchTable table, so even though it appears in the design of the form, it is not possible to modify the self-declaration
Why can't it be changed from there?
Don't you have access to the model in which the custom field was added?
Hello Angel,
Being a custom field, the easiest way is to set the Autodeclaration to Yes from the designer.
Add the purchtable extension form object to a project with the custom Model.
Correction. I need to be able to change the enabled property, it would be easier if I could do it from the self-declaration, but it can't be changed from there. That's why I resort to accessing from the form's control with FormControl, but when I do this it gives me an error that the indicated control cannot be found inside the form.
André Arnaud de Cal...
291,971
Super User 2025 Season 1
Martin Dráb
230,846
Most Valuable Professional
nmaenpaa
101,156