- Mastering ServiceNow Scripting
- Andrew Kindred
- 686字
- 2021-06-24 19:08:38
Script editor
When you encounter a script field in ServiceNow, it will have some additional features that allow you to create your scripts with greater ease than you would in a simple text field. This type of field is named a script type and is found throughout ServiceNow.
We will now look at this field type in detail so you can use this field to its best and understand the capabilities it has. First, let's take a look at this field in Figure 1.2:

There are a number of buttons above the field that you can use to your advantage. Let's take a look at these buttons in order, as each can assist with the code we write:
- Scroll: The scroll allows us to switch the syntax highlighting and script formatting on and off. It is on by default, which most will find the better option. However, if you would rather disable this and prefer writing in a simple text field, toggle this button to off. If toggled off, all the other buttons disappear to leave only a button which allows you to go to a specific line of code. Left on, this allows the script in the script field to be color coded, formatted with spacing to make it easier to read, and with syntax errors shown. The syntax errors will appear in the margin on the left, and you can hover over them to see the issue.
- Speech bubble: The speech bubble toggles whether the current line of script you are on is commented or not. A lot of developers will simply edit the script field itself, but it can be useful for multiple lines.
- Aligned text: This button formats the code in the script field. It will indent script in if statements and loops and makes the code a lot easier to read. This is a button I find very useful.
- Replaced letters: This button allows you to replace words or phrases in the script with different text. This is done for each instance of the word or phrase that you find, so you can replace many or a few of the words or phrases.
- Replaced letters with text: This icon is similar to the replace button, but it will replace all instances of a word or phrase without individually notifying you of each instance. For this reason, make sure you want to replace every specific word or phrase in the script field before using this icon.
- Magnifying glass: By clicking this button, we can search the text in the script field for a word or phrase.
- Down arrow: After performing a search, this allows the user to see the next instance of the searched for word or phrase.
- Up arrow: Once a search has been performed, this shows the previous word or phrase searched for in the script field.
- Boxed arrow: This toggles the script field between full screen and being a smaller box on the screen. This can be helpful when working on bigger scripts, to save from doing excessive scrolling.
- Question mark: Clicking this button shows a pop-up summary of the script editor and the shortcuts you can use.
- Disk: This saves the record, and the script, too.
- Ticked scroll: This toggles the syntax checking on and off. You will notice the left margin change size when this happens. Normally, the syntax checking is useful, but this does give the option to hide it if some of the syntax advice is not for you.
- Bug with scroll: By selecting this icon, the script debugger will open in a new window.
Some developers will have their own external scripting tools that they use to create the script and then paste it into script fields once complete. If doing this, ensure you have the latest version of the code in your external tool so that you do not overwrite updates from others by mistake.
This gives an overview of this type of field, and it makes scripting much easier. The syntax checking and code formatting are especially helpful tools.
- 數(shù)據(jù)展現(xiàn)的藝術(shù)
- 電力自動化實用技術(shù)問答
- 蕩胸生層云:C語言開發(fā)修行實錄
- 走入IBM小型機世界
- Photoshop CS4經(jīng)典380例
- Cloud Analytics with Microsoft Azure
- 微型計算機控制技術(shù)
- Apache Hive Essentials
- JMAG電機電磁仿真分析與實例解析
- 精通Excel VBA
- 運動控制器與交流伺服系統(tǒng)的調(diào)試和應(yīng)用
- 內(nèi)模控制及其應(yīng)用
- 網(wǎng)絡(luò)安全技術(shù)及應(yīng)用
- Microsoft System Center Confi guration Manager
- 氣動系統(tǒng)裝調(diào)與PLC控制