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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How to append text in to bottom of existing text in multiple lines of text field using javascript on condition met. How can i acheive this

(0) ShareShare
ReportReport
Posted on by 342

I need to append some text into bottom of existing text in the Multiple Lines of Text field in CRM on some condition met using Javascript on Onsave event. How can i achieve this

I have the same question (0)
  • Zakariae Benhallam Profile Picture
    75 on at

    Hello,

    The example bellow could help you.

    function addText(executionContext) {
        var formContext = executionContext.getFormContext();
        var textToAdd = "Lorem Ipsum";
        if (formContext.getAttribute("fieldName").getValue() != null) {
            formContext.getAttribute("fieldName").setValue(formContext.getAttribute("fieldName").getValue()   textToAdd);
        }
    }
    

    (if this answer helps, please mark it as verified)

  • Sandy Hello Profile Picture
    342 on at

    Hi Zakariae

    Thanks for your response.

    I want to add text with line breaks as below format.

    Text1

    Text2

    Text3

    when i am trying to add the text as above format i am getting error message. "ReferenceError: Web resource method does not exist"

  • Zakariae Benhallam Profile Picture
    75 on at

    Hello, 

    you can try this : 

    function addText(executionContext) {
        var formContext = executionContext.getFormContext();
        var textToAdd1 = "Text 1";
        var textToAdd2 = "Text 2";
        var textToAdd3 = "Text 3";
    
        if (formContext.getAttribute("fieldname").getValue() != null) {
            formContext.getAttribute("fieldname").setValue(formContext.getAttribute("fieldname").getValue()  " \n"  textToAdd1 "\n" textToAdd2 " \n" textToAdd3);
        }
    }
    

    And also please make sure that the function name on your form event handler is the same as on your webresource.

    (if this answer helps, please mark it as verified)

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 77

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 45 Super User 2026 Season 1

#3
sannavajjala87 Profile Picture

sannavajjala87 29

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans