Comments on: Dynamic browser window title script https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 21:58:34 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mark Stanger https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5935 Fri, 06 May 2016 11:33:32 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5935 In reply to Joshua.

It’s available by default now in Geneva.

]]>
By: Joshua https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5934 Fri, 06 May 2016 11:30:20 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5934 Hi All,
I came to know that this dynamic window title is available as OOB feautre in Geneva.
Is it true.
Or we need to do the above scripts to achieve the dynamic window title

]]>
By: Mark Stanger https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5933 Fri, 06 Jun 2014 04:46:09 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5933 In reply to MG.

Not until now :). Try out the updated script above and let me know how it goes.

]]>
By: MG https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5932 Thu, 05 Jun 2014 22:42:18 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5932 Any updates on being able to display a knowledge article’s title when viewing a knowledge article?

The script works of course when editing the article (since it’s a form), but the reeeeally helpful boost would be when viewing the article.

]]>
By: Mark Stanger https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5931 Thu, 02 Aug 2012 21:59:42 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5931 In reply to Roger E.

Nice! Thanks for sharing.

]]>
By: Roger E https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5930 Thu, 02 Aug 2012 21:41:43 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5930 Hi,

We actually prefer to use our pre-defined title (which is different in each environment) when a custom one cannot be used. We’ve also see that this client script is not fired off on list views so the window title will continue to be INC – DESC after the user has left the page. For this reason, we modified your version a bit to help w/ these scenarios.

We basically store the pre-existing title and put a bind on the unload event so it will be restored after you leave the page.

addLoadEvent(setTitle);

function setTitle() {
    var title = top.document.title;

    try {
        var num = g_form.getValue('number');
        var sd = g_form.getValue('short_description');
        var nme = g_form.getValue('name');

        if( (num != '') && (sd != '') ){
            top.document.title = num + ' - ' + sd;
            restoreTitle(title);
        }
        else if( (typeof nme != "undefined") && (nme != 'undefined') ){
            top.document.title = nme;
            restoreTitle(title);
        }

    } catch(e) {
        // Do nothing
    }
}

function restoreTitle(original_title) {
    // change the title back when we leave
    $j(window).unload(function() {
        top.document.title = original_title;
    });

}
]]>
By: Mark Stanger https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5929 Mon, 20 Jun 2011 06:58:41 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5929 In reply to Bill Collins.

‘getCompanyID’ just gets you the sys_id. ‘getDisplay’ doesn’t exist…I think you meant ‘getDisplayValue’. Also, ‘getDisplayValue’ won’t work off of a sys_id string, you have to reference it from a GlideRecord. You’ll also want to be aware that this information will require you to log in again each time as you are testing since it all gets cached as the session is created. I’m also not sure that the client data is going to be available throughout the product, though it should be available on standard forms. I think this is what you are looking for…
[code]
var cmp = gs.getUser().getCompanyRecord().getDisplayValue();
[/code]

]]>
By: Bill Collins https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5928 Sun, 19 Jun 2011 20:44:56 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5928 In reply to Mark Stanger.

I can display company sysID as follows, but still lack the conversion to name.

UI Script

 
addLoadEvent(setTitle);
 
function setTitle(){
 
   try{
 
      var comp = g_user.getClientData('test');
 
   }catch(e){
 
   //alert('Error getting title info.');
 
}
 
   if(comp){
 
      top.document.title = comp + ' - IT Service Management Suite';
 
   }
 
   else{
 
      top.document.title='Service-now.com - IT Service Management Suite';
 
   }
 
}
 

Script Action

 
myCompany();
 
 
 
function myCompany() {
 
   var cmp = gs.getUser().getCompanyID();
 
   session.putClientData("test", cmp);
 
}
 

Tried: var cmp = gs.getUser().getCompanyID().getDisplay();

]]>
By: Mark Stanger https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5927 Sat, 18 Jun 2011 20:22:32 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5927 In reply to Bill Collins.

No because the script actions run server-side and this modification needs to be done client-side. You could modify the UI script above to perform an asynchronous call to the server to get the company data but that probably wouldn’t work very well. I’m not sure of a good way to do what you’re asking for off the top of my head.

]]>
By: Bill Collins https://servicenowguru.com/ui-scripts-system-ui/dynamic-browser-window-title-script/#comment-5926 Sat, 18 Jun 2011 19:44:07 +0000 https://servicenowguru.wpengine.com/?p=362#comment-5926 Mark, Do you think the Script Action “Set Theme” could be modified to change title based on user company?

]]>