Issue with appending fields

mania
Tera Contributor

Hi,

 

The Work Note Type should be appended to the Case Work Note (HTML filed) and made visible in the Activity section. Additionally, the Case Work Note text should be bold and set to 14pt font size.

Note: Case worknote which is mapped to the worknotes in activity

I have tried with business rule like below:

mania_1-1769502700410.png

if (!current.u_case_worknotes || current.u_case_worknotes.nil()) {

        return;

    }

 

    var notes = current.u_case_worknotes + '';

    var type = current.u_work_note_type || 'Current Status';

 

    // Clean HTML if pasted

    notes = notes.replace(/<\/?[^>]+(>|$)/g, '');

 

    // Prevent duplication

    if (notes.startsWith(type)) {

        current.work_notes = notes;

    } else {

        current.work_notes = type + '\n' + notes;

    }

 

    current.u_case_worknotes = '';

Out put:

mania_2-1769502803184.png

 

So i want the Worknote type "Current status" should be bold with sixe 14pt also with some colour like below:

mania_0-1769502668232.png

Can anyone please help on this, it will be useful.

Thanks!

 

2 REPLIES 2

Its_Azar
Kilo Sage

Hi there @mania 

 

Work Notes support limited inline HTML. In your script, HTML is getting stripped by the regex cleanup, which is why formatting isnt appearing.

 

if (current.u_case_worknotes.nil()) {
    return;
}

var notes = current.u_case_worknotes + '';
var type  = current.u_work_note_type || 'Current Status';

notes = GlideStringUtil.escapeHTML(notes);

var formattedType =
    '<div>' +
    '<span style="font-weight:bold; font-size:14pt; color:#0056b3;">' +
    type +
    '</span>' +
    '</div><br/>';

if (!notes.startsWith(type)) {
    current.work_notes = formattedType + notes;
} else {
    current.work_notes = notes;
}

current.u_case_worknotes = '';
☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

mania
Tera Contributor

Thanks for responding,

I applied the code which your provided but i am getting like the below

mania_0-1769506032260.png

Thanks!