Scripting Questions

jesusemelendezm
Mega Guru

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.

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

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


View solution in original post

9 REPLIES 9

Catalog client scripts are to be used on catalog items, record producers and order guides....on teh form level, ie on table you have to use client script


server side objects are business rule, script include etc


-Anurag

You forgot one on submit


my bad ..


add onSubmit to the list


-Anurag

dalton1
Giga Expert

Are there any items left to be answered? Could you kindly mark this thread as answered if otherwise so that other users can see the finality of the discussion. Thanks!