Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Call URL from ui macro

eashwar
Tera Contributor

Folks,

I am trying to generate a simple URL in UI macro and call. its failing sysparam needs a demiliter.

code:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

    <j:set var="jvar_n" value="add_me_${ref}"/>

    <span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">

          <span class="sr-only">Add me</span>

    </span>

  <script>

          function addMe() {

      var url = "https://"+window.location.hostname.toString()+"/kb_knowledge.do?sys_id=-1&amp;sysparam_query=short_descriptionLIKEMAJOR";

  window.open(url, "_blank");

      return false;

          }

    </script>

</j:jelly>

How to call a url with param value ?

Thank you,

Eashwar Elumalai

1 ACCEPTED SOLUTION

Joe McCarty1
ServiceNow Employee
ServiceNow Employee

Sorry the way I was doing it (i.e. based on the ui macro) required the form to be saved before it would work.   LIkely what was the issue.   This version does not:



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


    <j:set var="jvar_n" value="add_me_${ref}"/>


    <span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">


          <span class="sr-only">Add me</span>


    </span>




  <script>


  function addMe(reference)


  {


      window.open('$knowledge.do#/search?query=' + encodeURI(g_form.getValue('short_description')) + '$[AMP]order=default');


  }


  </script>



</j:jelly>


View solution in original post

22 REPLIES 22

Joe McCarty1
ServiceNow Employee
ServiceNow Employee

Sorry the way I was doing it (i.e. based on the ui macro) required the form to be saved before it would work.   LIkely what was the issue.   This version does not:



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


    <j:set var="jvar_n" value="add_me_${ref}"/>


    <span id="${jvar_n}" onclick="addMe('${ref}')" title="Add me" alt="Add me" tabindex="0" class="btn btn-default icon-default-knowledge-base">


          <span class="sr-only">Add me</span>


    </span>




  <script>


  function addMe(reference)


  {


      window.open('$knowledge.do#/search?query=' + encodeURI(g_form.getValue('short_description')) + '$[AMP]order=default');


  }


  </script>



</j:jelly>


Perfect. Thank you so much Joe. Really appreciate it.


it worked finally


Hi joe,


sorry didnt know how to contact you. You helped me with a solution last time. Do you anytime idea for this request.



Automatically backup completed update set by EOD



thank you,


Eashwar Elumalai