GlideAjax is not defined in UI macro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 07:00 AM
Hi All,
I'm calling GlideAjax from UI Macro , but I'm facing below error:
org.mozilla.javascript.EcmaError: "GlideAjax" is not defined.
Caused by error in ftp://gsft_database/asp_cms_header_user_welcome.3 at line 2
1:
==> 2: var ga = new GlideAjax('global.GetHostName');
3: ga.getXMLWait();
4: var hostName = ga.getAnswer();
5:
My UI Macro looks like below:
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var ga = new GlideAjax('global.GetHostName');
ga.getXMLWait();
var hostName = ga.getAnswer();
</g:evaluate>
<!--<j:set var="jvar_inc" value="${help_sysid}" />-->
<span id="asp-cms-user-salutation">
${gs.getMessage('Welcome')},
<j:if test="${!gs.getUser().isXML()}">
<span id="asp-cms-user-name"><a href="profile.do">${gs.getUserDisplayName()}</a></span>
<span id="asp-cms-user-sysname">${hostName}</span>
</j:if>
</span>
</j:jelly>
What I'm doing wrong here ??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 07:20 AM
evaluate tags are like server side scripting. You can call the scripts directly as below.
var script = new scriptinclude();
script.functionname();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 10:04 AM
Thanks for the info, I would need to print user's computer name in ess page,
how can I do that, some link or info would be much appreciated,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 10:16 AM
Hi Rakesh,
When you use <g:evaluate> tag you can use that variable in html section as below:
the variable jvar_computerName has the value
<g:evaluate var="jvar_computerName" jelly="true">
// query whatever table you want and store it in variable and then you can use it in html
var gr = new GlideRecord();
gr.addQuery();
gr.query();
var computerName = gr.computer_name; // have your field here which stores computer name
computerName;
</g:evaluate>
<p>${jvar_computerName}</p>
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 10:36 AM
Hi Ankur,
We don't save computer name in table, I would like to display computer name dynamically for end user.
Is this possible ?
I tried with HostNameJs but it's not working as expected.