We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

GlideAjax is not defined in UI macro

rsadhula
Mega Contributor

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 ??

5 REPLIES 5

Deepak Ingale1
Mega Sage

I am not the expert in UI macros and UI pages, but looks like <g:evaluate> tag supports Server side code.


GlideAjax is client side API which allows to execution of code on Service Side.