Work Notes Syntax Highlighting

adaml
Mega Expert

Is it possible for Work Notes to contain Syntax Highlighting? For instance, users would like to add a work note to an Incident that might refer to some code. For instance the ">>" (Insert) button on this form allows me to add syntax markup like this:

This is my syntax highlighting

It's nice because it's visually separate from my other note

so people know exactly what i'm referring to in my other note details..

Is there any way to do something similar to this in an actual work note, or does anyone suggest anything similar?

Thanks!

7 REPLIES 7

Decades of practice.


User145619
Giga Expert

Hi I found one more way to do it recently. I did for url's i think same can be done for formatting aswell. You can do it in client scripts, it slows the performance a bit when you're typing in worknotes, but if customer demands, then these might be useful.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


if (oldValue==='' && newValue!=''){


    //Type appropriate comment here, and begin script below


var new_comments = g_form.getValue('comments')+'';


if(new_comments!='' && /http/.test(new_comments) && /code/.test(new_comments)===false){


  g_form.setValue('comments', urlify(new_comments));


}


// check notes and add href


var new_notes = g_form.getValue('work_notes')+'';


if(new_notes!='' && /http/.test(new_notes) && /code/.test(new_notes)===false){


  g_form.setValue('work_notes', urlify(new_notes));


}


}


// function to create link


function urlify(text) {


var urlRegex = /(https?:\/\/[^\s]+)/g;


return text.replace(urlRegex, function(url) {


  return '[code]<p><a class="web" target="_blank" href="' + url + '">' + url + '</a></p>[/code]';


});


}


  return;


}


User145619
Giga Expert

And you can close the thread if you find the answer in the above solution i have provided.