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 / Rich Text Editor Contr...
Power Apps
Answered

Rich Text Editor Control not displaying content populated from JavaScript

(0) ShareShare
ReportReport
Posted on by 311
In our model-driven app, we have a custom field of type multi-line text.  On a form, we're using the "Rich Text Editor Control" component for that field.  When we populate the content for that field from JavaScript, that content is not visible in the control.  The data is somehow there, but not visible.  If I save & close the record then re-open it, it shows up.  If I switch to the "Multiline text" component, it populates just fine.  But we need the rich text capabilities.
 
Here is the JavaScript line of code:
 
formContext.getAttribute("xyz_body").setValue("This is a test");
 
It used to work properly, up to maybe a month ago.  But I don't know exactly when it stopped working.  Has anyone else run into this?
I have the same question (0)
  • Suggested answer
    SaiRT14 Profile Picture
    1,990 Super User 2025 Season 2 on at
    Hi ,
     
    The Rich Text Editor control needs to be notified to refresh its display after setting the value programmatically.
    function setRichTextValue(executionContext) {
        var formContext = executionContext.getFormContext();
        var fieldName = "xyz_body"; // Replace with your field's schema name
        // Set the value programmatically
        formContext.getAttribute(fieldName).setValue("This is a test");
        // Trigger the control to refresh
        var control = formContext.getControl(fieldName);
        if (control && control.getControlType() === "richtext") {
            control.setFocus(); // Focus on the control to force rendering
            control.fireOnChange(); // Trigger the change event to refresh the control
        }
    }
     
    pls try. thanks
  • tschopp Profile Picture
    311 on at
    @SaiRT14 - I tried your suggestion, although modified slightly, and still doesn't work.  I was having trouble getting the controlType validation to work, so took that out.  And the fireOnChange() event only works for attributes, not controls.  So change that to getAttribute to get through that error.  I can see the cursor gets placed inside the rich text editor, so the setFocus() must be working.  But the content does not appear.  Here is my code:
     
    formContext.getAttribute("xyz_body").setValue("This is a test");
    formContext.getControl("xyz_body").setFocus();
    formContext.getAttribute("xyz_body").fireOnChange();
     
  • Verified answer
    tschopp Profile Picture
    311 on at
    Today, we found that this issue is no longer happening in all of our environments.  We didn't make any changes.  So, Microsoft must've fixed it.

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard