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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 60 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 51

#3
Satyam Prakash Profile Picture

Satyam Prakash 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans