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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Changing background color for model driven app

(0) ShareShare
ReportReport
Posted on by 2,563 Super User 2026 Season 1

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,695 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,563 Super User 2026 Season 1 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 426

#2
WarrenBelz Profile Picture

WarrenBelz 381 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 315 Super User 2026 Season 1

Last 30 days Overall leaderboard