How to add new line in client script

priyankagavali
Tera Contributor
How to add new line description field in below client script?
Tried "\n" thing but not working out.

I need description should be look like ,
Description from group: answer
descValue

function
onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
        return;
    }
    var descValue = g_form.getValue('u_description');
    var grSysUtils = new GlideAjax('global.sysUtils');
    grSysUtils.addParam('sysparm_name', 'getGroupDesc');
    grSysUtils.addParam('sysparm_groupName', newValue);
    grSysUtils.getXML(updateDesc);

 

    function updateDesc(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (descValue != "") {

//Need to add new line in below line

            g_form.setValue('u_description', "Description from group:" + answer + '\n' + descValue);
        } else {
            g_form.setValue('u_description', answer);
        }
    }

 

}
6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @priyankagavali 

 

Practically it should work

 

g_form.setValue('comments', exp_id + '\n' + model_name + '\n'+ desc );

 

https://www.servicenow.com/community/developer-forum/how-to-break-line-in-setvalue/m-p/2355518

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

_Gaurav
Kilo Sage

Hi @priyankagavali 
In my case, it is working as expected, this is how we break the line in CS.
Could you please share how you're getting the value in the description field?

Thanks!

Getting like this,
Description from group:testanswer

@priyankagavali 
I am believing the description field is the multiline text right that we usually have OOTB.