background script to update a description field of a record

skumar_srbh
Tera Guru

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....

 

 

 

1 ACCEPTED SOLUTION

Rishabh Jha
Mega Guru

Hi @skumar_srbh ,

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/)

View solution in original post

6 REPLIES 6

Rishabh Jha
Mega Guru

Hi @skumar_srbh ,

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/)

It works well... 

Thanks....  Rishabh.