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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

is this the formContext version of foreach?

(0) ShareShare
ReportReport
Posted on by

Is the upgrade from Xrm.Page version I found elsewhere?

                    formContext.ui.controls.forEach(function (control, i) {
                        if (control && control.getDisabled && !control.getDisabled()) {
                            control.setDisabled(true);
                        }
                    });

And if I wanted to limit this to just the attribute controls, how do I use this feature I found in the documentation:

formContext.data.entity Attribute.controls

Tia

I have the same question (0)
  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    About the difference between "formContext.ui.controls" and "formcontext.data.entity.Attribute.controls", you could refer to the following picture.

    pastedimage1583981593676v1.png

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/clientapi-form-context

    Actually, they have the same function. ui.controls could get all the controls on the current page and entity.attribute.controls could get the controls on the current entity form.

    If you only want to get the attribute controls in entity form, you could use formContext.getControl() to do actions on controls.

    Best Regards,

    Leo

  • Community Member Profile Picture
    on at

    Good reference!  Bad news is that I'm not someone who understands the statement "non-entity bound attributes."  Good news is that I think what I'm after is the other thing.

    So what I understand you are saying is that to avoid everything but on-form attribute controls the syntax is like:

    formContext.data.entity.attributes.forEach(attr, i)

    ...attr.controls.forEach(ctrl, j)...

    where most of the second forEach will handle only one control.

    NOTE: I tried doing the setDisabled on the attributes and nothing happened, probably because attributes are not controls.

    thanks again

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Actually your understanding is correct.

    In "forEach" cycle, you could handle only one control. And the reason why "setDisabled" is useless is that you should get the control to set disabled not attributes.

    As we can see in the doc, we should use formcontext.getControl().setDisabled();

    pastedimage1584323912585v1.png

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/setdisabled

    Hope it helps.

    Best Regards,

    Leo

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 192 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans