Call Script Include from Client Script in ServiceNow using GlideAjax

  Рет қаралды 15,481

Harshad Chawra

Harshad Chawra

Күн бұрын

Calling a Script Include from Client Scripts using GlideAjax in ServiceNow OR returning multiple values from a script include to the client script. This is helpful when we need to populate data for some other fields onchange of an existing field wherein we need to query the database using GlideRecord since the use of getReference or GlideRecord is not recommended in Client Scripts. Use of these might break functionality. For eg: same code with getReference or GlideRecord in client script will not work in the service portal while it looks to be working fine in the Platform.

Пікірлер: 31
@pampapathi7793
@pampapathi7793 4 жыл бұрын
It's very good explanation, please make it whole clientscript, business rules and ui policies it's very useful for us. Thanks
@theBeastMastersDojo
@theBeastMastersDojo 4 жыл бұрын
Thanks. I will create a few videos on the mentioned topics as well.
@sarahsanhithavemuri7604
@sarahsanhithavemuri7604 4 жыл бұрын
Thank you it is very useful
@srinivasarao2965
@srinivasarao2965 11 ай бұрын
If possible please share the piece of code where I am having first and last name variables in the catalog item and I have to auto generate the email before setting the auto generated email to the email it should validate if the email is already present in the user table or not if not it should set the value to the email field if it is present it should add the number to the end of the last name. The Validation of email should happen before submitting the form Thanks in Advance
@vishaljawalkar342
@vishaljawalkar342 2 жыл бұрын
thank you for guiding it the right way!! however I got a question. why doesnt getXML works instead of getXML Answer although both yielded the same logs
@theBeastMastersDojo
@theBeastMastersDojo 2 жыл бұрын
getXml returns the whole xml document so you will have to make an extra effort via code to fetch the response/answer from it whereas getxmlanswer gives you the exact response you are looking for without an additional effort.
@NEHA-ci3qi
@NEHA-ci3qi 2 жыл бұрын
Hii, there is a reference field called caller field when we select a user in the caller field then user email field should get populated after selecting caller field using client script and script include please tell me the solution for this paste here both scripts code... As early as possible please...
@4_Haters
@4_Haters Жыл бұрын
hello harshad can u make more videos on onchange client callable script include 1. if a user gone through a catalog form and when the user enters his email address and after making the check box type variable true then the details of user should be fetched it is like searching some thing in google
@theBeastMastersDojo
@theBeastMastersDojo Жыл бұрын
the same thing is already explained in this video. It will use the same concept of glideajax as already explained in this video. Is there a specific use case that you are not able to figure out even after watching this video?
@4_Haters
@4_Haters Жыл бұрын
@@theBeastMastersDojo i have a check box type variable when it is check to true then it has to fetch the other details
@theBeastMastersDojo
@theBeastMastersDojo Жыл бұрын
@@4_Haters this video is the exact demo you are looking for. On selection of checkbox just pass the appropriate values to glideajax to fetch the required information... That's it.
@mansigupta7291
@mansigupta7291 2 жыл бұрын
Script include is not callable from on submit ,can u make video on submit script include
@theBeastMastersDojo
@theBeastMastersDojo 2 жыл бұрын
what is your use case?
@srilatha-sn5vx
@srilatha-sn5vx 4 жыл бұрын
hi how to achieve :While creating a new Incident, check with CI, if already a CI exists in the incidents. Then assign new incident as child incident for existing Incident.
@theBeastMastersDojo
@theBeastMastersDojo 4 жыл бұрын
Write a before insert business rule on incident table. you can check current ci details using 'current.cmdb_ci' and then pass this as a parameter in your gliderecord query for incident table. If any such incident exists then update the parent for current incident to the one you found via gliderecord...
@snehaldixit1327
@snehaldixit1327 2 жыл бұрын
I have done the same as per my requirement....but it doesn't reflecting the values
@theBeastMastersDojo
@theBeastMastersDojo 2 жыл бұрын
did you check at script include end if the expected values are returned?
@mylittlejaanu5655
@mylittlejaanu5655 Жыл бұрын
Same script I tried but which is not working.. Please help on this
@theBeastMastersDojo
@theBeastMastersDojo Жыл бұрын
What is the issue?
@levanshiaa6946
@levanshiaa6946 4 жыл бұрын
I'm trying to do the same for the catalog item , well it's displaying on the try now catalog page but it's not displaying on Service portal, can you suggest what am I missing .
@theBeastMastersDojo
@theBeastMastersDojo 4 жыл бұрын
Make sure you have selected Ui type as 'All' in your client script for it to work in platform as well as portal.
@levanshiaa6946
@levanshiaa6946 4 жыл бұрын
@@theBeastMastersDojo Thank you, yes it's working after i choose UI type as 'all'
@playwithjava392
@playwithjava392 3 жыл бұрын
I tried this approach to populate the values in catalog form but in form it is populating "undefined" But in table corresponding data is present... Can u suggest any solution.
@theBeastMastersDojo
@theBeastMastersDojo 3 жыл бұрын
Add logs in your script include and check before returning anything whether there is a value or not
@playwithjava392
@playwithjava392 3 жыл бұрын
I treid with gs.info but some is coming ... Actually i want fetch the details from custom table and populate values on catalog form... In custom table i have 4 colum and one of then is snet with is unique... Ifuser will enter ip and first 3 sections of ip and snet first scectiob will match in that case that particular recod data will populate in catalog forms variables
@playwithjava392
@playwithjava392 3 жыл бұрын
I used gr. addQuery('snet', 'STARTSWITH',' ip') in ip i captured first 3 sections of user's ip adderess
@theBeastMastersDojo
@theBeastMastersDojo 3 жыл бұрын
@@playwithjava392 if you are getting data after your gr.query() runs then it should work fine. Whatever data you are returning from the script include, before returning convert it into a string and then add those variables to object and then return that object from the script include.
What to chose between g_scratchpad, getReference and GlideAjax in ServiceNow
24:36
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 32 МЛН
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 55 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 6 МЛН
GlideAjax Tutorial | ServiceNow (Live Coding)
19:29
Hardit Singh
Рет қаралды 5 М.
#4 OnChange Client Script in ServiceNow | Client Scripts in ServiceNow
17:46
Why UK 🇬🇧 is going Bankrupt? : Detailed Economic Case Study
20:37
Think School
Рет қаралды 1,3 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 32 МЛН