Browser Window Title - display task number (e.g. INC0000046)

nikita_mironov
Kilo Guru

Hi
I searched the forum and wiki but with no luck. Is there any tricky way to display the task number in browser window title, i.e. replacing ... with
? Refer to the attached screenshot.

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

I've used this script before. It sets both the number and short description if they are there. You'll need to use this code in a new UI script record under 'System UI -> UI scripts'.



addLoadEvent(setTitle);
function setTitle(){
try{
var num = g_form.getValue("number");
var sd = g_form.getValue("short_description");
}catch(e){
//alert('Error getting title info.');
}
if(num && sd){
top.document.title = num + ' - ' + sd;
}
else{
top.document.title='Service-now.com - IT Service Management Suite';
}
}


View solution in original post

10 REPLIES 10

Hi Mark.
Sorry. I wrongly created this script as onLoad script over the task table while I should have followed your instructions and created it in UI Scripts.
It works fine after I created it in the right place!
Sorry again.
Nikita


Hey Mark,

I like this script and was trying to get it running in my dev instance to try it out.

The UI Script doesn't appear to be firing though. I checked that it's active etc, but putting alert() debugging in showed that the function wasn't even firing.

Any advice on why this isn't working?


You probably don't have the 'Global' checkbox checked in the UI script. Without that, the function has to be called from another script. Check the 'Global' checkbox and it should work.


Hey Mark!!



I have a table displaying null on the window and used this script and it works perfectly! But the problem is, I need to reload the page after opening it, for it to capture the number and display. When I open it the first time, it still shows null. Is there something I'm doing wrong? Or is there a workaround? This is the script I'm using.



addLoadEvent(setTitle);


function setTitle(){


  try{


  var num = g_form.getValue('number');


  var nme = g_form.getValue('name');



  //Check if viewing a KB article


  if($('kb_view')){


  num = $('permalink').href.split('sysparm_article=')[1];


  sd = $$('.kb_article_header_short_description')[0].innerHTML;


  }


  if(num){


  top.document.title = num + ' | ServiceNow';


  }


  else if(nme){


  top.document.title = nme + ' | ServiceNow';


  }


  else{


  top.document.title='ServiceNow ITSM Suite';


  }


  }catch(e){


  //alert('Error getting title info.');


  }


}


Not applicable

Ah genius. The Global checkbox isn't visible on the UI Scripts form by default

Works like a charm now. I like it, and checking with the Service Desk guys they seem to like it too.