- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:24 AM
I am using below script to update the demand description field...
var gr = new GlideRecord('test_demand');
if (gr.get('b6a1c42cdb578c503b0cf5261d96196c')){
gr.setValue('long_desc', ' .... . .. . . . ');
gr.update();
gs.print('updated!');
}
else {
gs.print('nothing updated,..');
}
in the long description, i want to put the below text in same format.
"> this is the
description ...
and it should not be changed"
To get that I am using + and \n in the end of 1st and 2nd line and + in the starting of 2nd and 3rd... but it seems to be not working. is there any easy way/function to modify it... ? Please suggest...
Thanks in advance....
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 11:06 AM
Hi
Please try the snippet below in your background script, it should work.
var gr = new GlideRecord('test_demand');
if (gr.get('b6a1c42cdb578c503b0cf5261d96196c')){
gr.setValue('long_desc', "> this is the\n"+
"\n"+
"description ...\n"+
" and it should not be changed");
gr.update();
gs.info('updated!');
}
else {
gs.info('nothing updated,..');
}
Thanks & Regards,
Rishabh Jha
Aavenir (http://www.aavenir.com/)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:44 AM
I am not sure if I am understanding you correctly but I am assuming you want to update this ( "> this is the ) in the description field. As ( " ) is escape character so to print this you will need to attach ( \ ) with it.
Rest of the code is fine just make sure table name and fields names are correct. I tested and its working as expected.
var gr = new GlideRecord('test_demand');
if (gr.get('a9e9c33dc61122760072455df62663d2')){
gr.setValue('description', '\"> this is update');
gr.update();
gs.print('updated!');
}
else {
gs.print('nothing updated,..');
}
Please mark this ACCEPTED & HELPFUL if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 10:48 AM
Hi Sharjeel,
Thanks.....
"> this is the
description ...
and it should not be changed."
above text in exactly same format needs to be updated in the description field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 11:10 AM
I updated the code. Please cross check the table is demand or test_demand and make change to the table name accordingly, if required.
var gr = new GlideRecord('demand'); //YOUR TABLE NAME
if (gr.get('b6a1c42cdb578c503b0cf5261d96196c')){
gr.description = '\"> this is the '+'\n'+'description ...'+'\n'+' and it should not be changed."';
gr.update();
gs.print('updated!');
}
else {
gs.print('nothing updated,..');
}
Please mark this accepted & helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 11:03 AM
Hi skumar_srbh,
Please update the below script:
var gr = new GlideRecord('incident');
gr.get('878f10372f115010d1ea52492799b63d');
gr.description = '"> this is the '+'\n'+'description ...'+'\n'+' and it should not be changed."';
gr.update();
The output would be:
Add '\n' to place a new line.
Mark correct and helpful if it helps.
Thanks,
CB