Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How do I access a control with autodeclaration in no

(0) ShareShare
ReportReport
Posted on by 15

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?

pastedimage1677873105288v1.png

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

  • Angel Profile Picture
    Angel 15 on at
    RE: How do I access a control with autodeclaration in no

    thanks for you answer

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How do I access a control with autodeclaration in no

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: How do I access a control with autodeclaration in no

    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.

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: How do I access a control with autodeclaration in no

    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

  • Angel Profile Picture
    Angel 15 on at
    RE: How do I access a control with autodeclaration in no

    Yes, the purchtable was extended in my model, however, I can't modify the autodeclaration because it appears disabled

    pastedimage1677874831602v1.png

    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

  • Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: How do I access a control with autodeclaration in no

    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 ?

  • Angel Profile Picture
    Angel 15 on at
    RE: How do I access a control with autodeclaration in no

    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

  • Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: How do I access a control with autodeclaration in no

    Why can't it be changed from there? 

    Don't you have access to the model in which the custom field was added?

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: How do I access a control with autodeclaration in no

    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.

  • Angel Profile Picture
    Angel 15 on at
    RE: How do I access a control with autodeclaration in no

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans