web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Released product form readonly in unit test

(0) ShareShare
ReportReport
Posted on by 133

Good day everyone,

I've got a question regarding the use of the test framework for forms. I have some custom code that sets some fields to not editable in the EcoResProductDetailsExtended form if some criteria are met. The code itself works fine. However, I also wanted to write some unit tests for this, to easily test my code in future upgrades etc.

So what I did:

- Recorded a task in F&O via the task recorder

- Downloaded the recorded task and imported it as unit test in Visual Studio via Extensions -> Dynamics 365 -> Addins -> Imported task recording

- Modified the generated code to write 2 test methods. One test to verify that the fields are editable in scenario 1, and another test to verify that the fields are readonly in scenario 2.

To my suprise however, the fields are readonly in both cases. Just to be sure, I disabled all my custom code for these fields, but still the fields are readonly.

This is my test case (slightly simplified to show only relevant parts):

class MyFormTest extends SysTestCase
{
    protected EcoResProductDetailsExtendedFormAdaptor EcoResProductDetailsExtendedForm;

    public void testFieldEditable()
    {
        changecompany('XXXX')
        {
            using (var c = ClientContext::create())
            {
                //Go to Product information management > Products > Released products.
                using (var c1 = c.navigate(menuItemDisplayStr(ecoresproductdetailsextendedgrid),formStr(EcoResProductDetailsExtended),Microsoft.Dynamics.TestTools.Dispatcher.MenuItemType::Display))
                {
                    EcoResProductDetailsExtendedForm = c1.form();

                    //In the list, click the link in the selected row.
                    EcoResProductDetailsExtendedForm.HeaderGrid().selectRecord();
                    EcoResProductDetailsExtendedForm.systemDefinedViewEditButton().click();

                    this.assertTrue(EcoResProductDetailsExtendedForm.EcoResProduct_SearchName().editable());
                }
            }
        }
    }
}

In my test setup (not included in the snippet) I made sure company XXXX is created, and has 1 released product. I checked that the grid contains 1 product by adding the following debug line to the test.

Info(int2Str(EcoResProductDetailsExtendedForm.HeaderGrid().count()));

Anyone got an idea why this test fails? Am I missing some setup to be able to edit a product via the form in my unit test? I have been writing more unit tests in Dynamics, but this is my first test involving forms like this.

I have the same question (0)
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    As far I know the released products form is non editable from UI. It is same at list page level and at item level also. Only may be custom fields would be editable. Are you asking this only?

  • FV@E Profile Picture
    133 on at

    When I open the UI the field can be edited normally:

    pastedimage1681389858670v1.png

    Only during my unit test the editable() seems to return false.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 558 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 402

#3
Diego Mancassola Profile Picture

Diego Mancassola 261

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans