Thursday, 21 September 2023

Remove Html Div tags from comments and save in another field - Dynamics CRM

 CODE: 

function onChangeComments(executionContext) {
var formContext = executionContext.getFormContext();
var new_comments = convertToPlain(formContext.getAttribute("new_comments").getValue());

 

formContext.getAttribute("new_copycomments").setValue(new_comments);
}

 

function convertToPlain(html){

 

    // Create a new div element
    var tempDivElement = document.createElement("div");

    // Set the HTML content with the given value
    tempDivElement.innerHTML = html;

    // Retrieve the text property of the element 
    return tempDivElement.textContent || tempDivElement.innerText || "";
}

No comments:

Post a Comment

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...