Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

JavaScript won't update a field on a form header

Posted on by 509

I've got two field which I've placed on the header one to show a custom "Status" and a second one for the "Sub Status".

I've added an additional "Status" field on the main body of the form ( hidden) as you cannot add an OnChange event to this field from the header.

However when I perform this onChange event from the Status in the header, I get an error popping up which status the field is "null" - it's a hidden field (part of the code makes it visible). It's clearly next to the form field.

If I add the "Sub Status" field to the main body of the form, i do not get this error, except it appears on the main body of the form where it is not required and the field in the header does not appear.

It is a business requirement that these fields appear in the header.

Also in the form DESIGN I've placed the "Status" in column 3 of the header and yet in the UI it is moved to column 4. - How do I maintain the integrity of the form design layout?

  • Lee-Martin Profile Picture
    Lee-Martin 509 on at
    RE: JavaScript won't update a field on a form header

    Thank you, that's solved the code working on the "Sub Status" field in the header.

    However, this is now a bigger issue

    Also in the form DESIGN I've placed the "Status" in column 3 of the header and yet in the UI it is moved to column 4. - How do I maintain the integrity of the form design layout?

    The new field appears where I have placed it, but now the status moves to the left when the sub status appears in it's selected 4th column.

    In theory I can just make the "Sub Status" readonly until the Status is selected, but in reality we do need to make sure integrity of the form layout is maintained.

    In addition, is there a quick JavaScript line which I can use to restore the default list of options via an onchange event?

  • Suggested answer
    T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: JavaScript won't update a field on a form header

    Have you tried appending header_ to your field in JavaScript e.g. formContext.getAttribute("header_yourfield").getValue();

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans