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 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
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)
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"
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)
André Arnaud de Cal... 291,759 Super User 2024 Season 2
Martin Dráb 230,468 Most Valuable Professional
nmaenpaa 101,156