How to add spaces on Journal field/work notes of RITM when updating this from script

Naveen Thadur1
Tera Contributor

Hi I am trying to update the work notes of RITM from a Business rule .

I want to align variables value , so adding spaces but it takes only one space.

My code is like 


var variables='Requirement Details :\n'+"\n";
//variables+= 'sfdb:'+current.variables.investment_name_short_description.getDisplayValue()+"\n"+"\n" +"\n";
variables+= 'Skill          :'+" "+': '+current.variables.skill.getDisplayValue()+"\n"+"\n";
variables+= "Skill S ID" +" "+ " "+ '&nbsp &nbsp  + current.variables.skill_sub_id.getDisplayValue()+"\n"+"\n";
variables+= 'Skill Descript'+ spaces(10) +":" +current.variables.skill_description.getDisplayValue()+"\n"+"\n";

current.work_notes=variables;

 

I tried /s , &nbsp etc but nothing worked.

How can i fix this ?

1 ACCEPTED SOLUTION

Chander Bhusha1
Tera Guru

Hi naveen.sharan,

The \t or &nsbp; will add only one spaces in between. So you have to use the <pre> tag in the script and format the code in which you want and the same way it will apprear.

You have to use <BR> for inserting a new if you are using pre tag.

IN the start you have to add [code]<pre>  and after end of the full notes you have to close this tag </pre>[/code] like we do for HTML tag.

 

We also have used this approach for constructing the formatted string.

The script which I have written : You can replace hihih with the variable name and try.

var gr = new GlideRecord('incident');
gr.get('0544020e07e5941046c7fd908c1ed0bc');

var variables='[code]<pre> Requirement Details :'+'<BR>';
variables+= 'sfdb:                     '+'hihiihi' +"<BR>";
variables+= 'Skill:                    '+'newowlkwel'+"<BR>";
variables+= "Skill S ID :                "+ 'jakfjladsjfa'+"<BR>";
variables+= 'Skill Description:           '+ 'test' +"<BR>"  +"</pre>[/code] ";



gr.work_notes=variables
gr.update();

 

Output:

find_real_file.png

 

 

 

Mark helpful and correct if it helps.

Thanks,

CB

 

View solution in original post

3 REPLIES 3

Akshata jamdar
Mega Guru

 Hello naveen.sharan,

 

You can add variables into an array and then setValue in work note with white spaces "+".

 

Please let me know if it works.

 

Regards,

Akshata

Chander Bhusha1
Tera Guru

Hi naveen.sharan,

The \t or &nsbp; will add only one spaces in between. So you have to use the <pre> tag in the script and format the code in which you want and the same way it will apprear.

You have to use <BR> for inserting a new if you are using pre tag.

IN the start you have to add [code]<pre>  and after end of the full notes you have to close this tag </pre>[/code] like we do for HTML tag.

 

We also have used this approach for constructing the formatted string.

The script which I have written : You can replace hihih with the variable name and try.

var gr = new GlideRecord('incident');
gr.get('0544020e07e5941046c7fd908c1ed0bc');

var variables='[code]<pre> Requirement Details :'+'<BR>';
variables+= 'sfdb:                     '+'hihiihi' +"<BR>";
variables+= 'Skill:                    '+'newowlkwel'+"<BR>";
variables+= "Skill S ID :                "+ 'jakfjladsjfa'+"<BR>";
variables+= 'Skill Description:           '+ 'test' +"<BR>"  +"</pre>[/code] ";



gr.work_notes=variables
gr.update();

 

Output:

find_real_file.png

 

 

 

Mark helpful and correct if it helps.

Thanks,

CB

 

Hi, this solution is not working in Rome for me, is this no longer supported