Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to enable/disable form data source property

(0) ShareShare
ReportReport
Posted on by 524

Hi Guys,

In the standard form data source consist of field ,in which field has the properties called as("Visible" - No) ,how to enable this through code in d365 ,and i can't able to change the property manually.

please help me to solve this requirement.

  • Verified answer
    Blue Wang Profile Picture
    on at
    RE: How to enable/disable form data source property

    Hi Jenifer,

    You can override active() method of your datasource, then add this code :

    Table_ds.object(fieldNum(YourTableName,YourField)).visible(true);

    The effect is as follows:

    Before adding:

    72811.PNG

    After adding:

    6355.PNG

  • Verified answer
    Khushhal Garg Profile Picture
    1,514 on at
    RE: How to enable/disable form data source property

    You can change data source field property oninitialized event if you are looking to change the property while opening the form

  • Verified answer
    Pedro Tornich Profile Picture
    955 on at
    RE: How to enable/disable form data source property

    Hi Jenifer,

    Usually fields set as Visible::No have their visibility handled by code.

    So, if you search the form for the field name you will probably find some logic to turn its visibility on/off.

    I would advise you to understand what business rule drives the field visibility prior to writing any code, most cases like this end up being configuration related.

    Anyway, if after understanding the visibility rules behind the field you still need to change its visibility by code you will need an event handler (or CoC), since you are talking about an out of the box form.

    Here is an example:

    [FormEventHandler(formStr(CustTable), FormEventType::PostRun)]
    public static void CustTable_OnPostRun(xFormRun sender, FormEventArgs e)
    {
        sender.dataSource(formDataSourceStr(CustTable, CustTable))
            .object(fieldNum(CustTable, AccountNum))
            .visible(true);
    }

    In this example I used the OnPostRun event of the CustTable form to change the visibility of the CustAccount field.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    293,278 Super User 2025 Season 1 on at
    RE: How to enable/disable form data source property

    Hi Jenifer,

    You can actually create a display method to show the contents of the field. What is it exactly what you want to achieve? There is usually a design reason why fields are set to be not visible.

  • Suggested answer
    Adria Ariste Profile Picture
    User Group Leader on at
    RE: How to enable/disable form data source property

    Hi,

    it depends on your requirement but you can call the following on your DS methods, for example to disable editing on a DS field:

    formDataSource.object(fieldnum(Table, Field)).allowEdit(false);

    You can call several methods to access properties (like enabled or visible).

    But as I said this depends on your requirements. And if you're doing this on a custom form, an event handler, an extension, etc...

    Adrià Ariste - Senior technical consultant @ Axazure - Read my blog!

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February 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... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans