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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Changing background co...
Power Apps
Unanswered

Changing background color for model driven app

(0) ShareShare
ReportReport
Posted on by 2,429 Super User 2025 Season 2

Hi everyone,

 

it seems that the problem still persists.

I want to change the colour of my model driven app text input field. Using JS, it generally seems to be possible.

 

I achieved the following with a direct console execution of:

document.querySelector("[data-id=cdt_p_familienname] input").style.backgroundColor = "rgb(255,199,206)"

Lucas001_0-1702897186037.png

 

 

Problem is I usually would implement my <script></script> in the end to be loaded last. Seems not to be possible in MDAs.

I now tried the .OnLoad()-Event of the form itself. Unfortunately it seems that the OnLoad event fires before the DOM is loaded in some way. When outputting the HTML using window.document I just get some scripts. 

Lucas001_1-1702897424863.png

Even using a setTimeout() does not work as the script seems to only get elements which are within or executed before the form OnLoad().

 

Anyone knows why it behaves like that?

 

 

Categories:
I have the same question (0)
  • Verified answer
    Jonathan Manrique Profile Picture
    2,687 on at

    Hi @Lucas001 

     

    In Model Driven Apps applications it is not possible to make these types of changes with Javascript because you must have to modify the html of the application and it is something that is not recommended to do and can damage the application.

     

    Now there are options under the PCF components for what you mention, you can develop PFC or pull from the existing community gallery

     

    https://learn.microsoft.com/en-us/power-apps/developer/component-framework/overview

    https://pcf.gallery/

     

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
    You can accept more than one post as a solution

  • Lucas001 Profile Picture
    2,429 Super User 2025 Season 2 on at

    Hi @Jmanriquerios,

     

    thanks for the reply. I assumed it's as you say, still hoped differently.

    I will try starting with a PCF than.

     

  • DW-07111621-0 Profile Picture
    2 on at
    I  tried to change a section colour  via an event handler on Form Load.  
     
    const dataId = `tab_details_section_holidays`
    document.querySelector(`section[data-id="${dataId}"]`) as HTMLElement;
     
    However, the code would never find the element so thinking this not supported.   Can you use a custom PCF control to build your own section element?
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard