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.

Can we use jQuery in ServiceNow

sia2
Mega Contributor

Hi All,

I am just a starter in ServiceNow. Want to know if we can use jQuery in ServiceNow where ever we can use Javascript?

If yes..... Please let me know the whole procedure.

5 REPLIES 5

ProbirDas
Tera Expert

sia2
Mega Contributor

Hi Probir Das,



Thanks for your reply.


I tried grasping things in both the articles and end up with nothing.



Can you please tell me what should I do in order to run the below code successfully in Client Script?



$(document).ready(function(){


        $("p").click(function(){


                $(this).hide();


        });


});


sia2
Mega Contributor

Any luck?


sia2
Mega Contributor

Hi All,



Here is the solution.



I have successfully implemented your code in a Client Script as detailed below:


  1. In your test instance, access:

System Definition -> Client Scripts


  1. Click "New"
  2. Fill in the form as follows:

* Enter a name (I used jQueryTest)


* Select "Incident" table


* Type: onLoad


* Global and Active ticked


* Script:



function onLoad() {


//Type appropriate comment here, and begin script below


var $j = jQuery.noConflict(true);


$j(document).ready(function(){


$j("p").click(function(){


$j(this).hide();


});


});


}



  1. Click Save


  1. Open any incident and enter a comment as below:

(Please remove the underscore _ from both code tags, I had to include it to ensure it is formatted correctly)


[co_de]


<p>test</p>


[/co_de]



  1. Click the "test" comment to see it disappear.