- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2014 07:34 PM
These days I have been learning how to use ServiceNow scripts. I was stuck- in couple of scripts one in a UI action and another one in an e-mail template. I received help from various users here which I really appreciated. While navigating the scripts, testing and so on, I've collected the following questions. Some of them are very basic and I look to clarify/confirm with your help.
1) How do you quickly differentiate between a block of client script and server script?
2) Where can I use client side script and where I cannot?
3) Where can I use server side scripts and where I cannot? Where can I use both?
4) E-mail template script — if I am using tags <script> statement </script> this indicates that I am using client script. Between these tags, can I not use server scripting?
5) How do you easily verify syntax on e-mail templates?
6) When referring to referenced field values- you have to use Sys_ID?
7) When referring to strings values in a field you can use quotes'' '' (e.g. short_description = 'desktop broken')?
😎 When referring to choice type fields — It is necessary to use the numeric value (e.g. state: cancelled — value: 7)?
9) Where can I use HTML tags to change appearance of texts and numbers?
10) You can build a query from lists and copy the query. Where do you use these queries? For example: (descriptionLIKEtex) when I look for a description that contains word letters tex. I meant, what's the usability of copying queries from a list- can these be used in a script? How?
11) Where can I have a list of out-of-the-box functions that I can use? For example, function onCellEdit, onChange, onLoad, etc.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2014 09:12 PM
i will try answering your questions
1. if there is g_form, it is client side... if it has gs. , it is server side (this will hold good in most places)
2. client script -> client script, ui policy, ui action, catalog client script, catalog ui policy, ui script, ui macro,ui page, etc
3. server script -> script include, BR, scheduled job, ui action, etc
4. use <mail_script> for writing server side code
5. I do not think there is a way of doing this... But i use editor while using <mail_script>
6. But default it gives sys_id... but you can dot walk to access any other field too...
7. for string you can use both " or '
8. it is not neccessary to use string values
9. if it field, right click -> personalize style -> use your HTML....
10. you can right click and copy the queries and you can use 'addEncodedQuery' for gliderecords instead of individual addQuery on fields.
11. I am not sure what you are referring here. But these are 3, that I am aware of that is available on client scripts...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2014 09:12 PM
i will try answering your questions
1. if there is g_form, it is client side... if it has gs. , it is server side (this will hold good in most places)
2. client script -> client script, ui policy, ui action, catalog client script, catalog ui policy, ui script, ui macro,ui page, etc
3. server script -> script include, BR, scheduled job, ui action, etc
4. use <mail_script> for writing server side code
5. I do not think there is a way of doing this... But i use editor while using <mail_script>
6. But default it gives sys_id... but you can dot walk to access any other field too...
7. for string you can use both " or '
8. it is not neccessary to use string values
9. if it field, right click -> personalize style -> use your HTML....
10. you can right click and copy the queries and you can use 'addEncodedQuery' for gliderecords instead of individual addQuery on fields.
11. I am not sure what you are referring here. But these are 3, that I am aware of that is available on client scripts...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 11:16 AM
Thanks for your help this clarifies a lot.
My last question was on functions, If I understand correctly... there are a number of out of the box functions that I can use ease coding additionally I can create my own JavaScript functions depending on what I wannna do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 11:34 AM
client script are three types onload, onchange and celledit as far as i know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2014 06:24 AM
Kalaiarasan,
Basically, in every area where I can use server script I also can use client script but where I can use client script I cannot use server script example "Catalog Client Script".
Regards
Jesus.