Skip to main content

Notifications

Announcements

No record found.

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 340

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

  • RE: 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

    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)

  • Sandy Hello Profile Picture
    Sandy Hello 340 on at
    RE: 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

    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"

  • RE: 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

    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)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans