Developer Function: Server Script: Debug
## Overview
Describes how to line debug "「Server Script」" using Visual Studio Code.
## Limitations
1. During debugging, the script will pause midway until the debugger connects, making the table unavailable. Do not use this in a production environment.
## Prerequisites
1. Port 9222 must be open on the server where Pleasanter is running.
1. Visual Studio Code must be installed on the PC used for debugging.
## Operation Procedure
1. Create an arbitrary working folder. *Here we will use the work folder.
1. Create a .vscode folder inside the working folder.
1. Create a launch.json file inside the .vscode folder.
1. Launch Visual Studio Code and open the work folder. *When the work folder is opened in Visual Studio Code, the left side EXPLORER will look like this:

1. Change the address in launch.json to the server address.
1. Access Pleasanter in a browser and add //debug// to the first line of the "「Server Script」" you want to debug, then save it.
1. Open the "「Table」" you want to debug. The server script will be in debug mode and standby, with no response on the screen.
1. In Visual Studio Code, select Run → Start Debugging.
1. The source code is loaded into Visual Studio Code and line debugging is enabled.
## launch.json
This file contains the connection information to the Pleasanter environment to be debugged. Change the address as needed. If Pleasanter is on the local PC, specify localhost.
##### JSON
```
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to ClearScript V8 on port 9222",
"type": "node",
"request": "attach",
"protocol": "inspector",
"address": "192.168.1.101",
"port": 9222
}
]
}
```
## Example Debug Script
By adding //debug// at the beginning, the script will pause when executed, allowing for debugging. Remove //debug// when not debugging. In the server script example below, the context.Log() method outputs logs to the console in the browser's developer tools.
##### JavaScript
```
//debug//
if (context.UserId === 1) {
context.Log('User ID is 1');
} else {
context.Log('User ID is not 1');
}
```
## Related Information
<div id="ManualList">
<article class="s-blog_list_unit"><h2>
<h2>The specified information was not found.</h2>
<p><a href="/ja/manual">Return to top</a></p>
</article>
</div><input id="SearchTextHidden" type="hidden" value="" />