User Manual

08.14.2024

MANUAL

Developer Function: Server Script: Debug

## Overview Describes how to line debug "[Server Script](/en/manual/table-management-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: ![image](https://pleasanter.org/binaries/024f47dd871a44b8a2ef1f345b43ef1d) 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](/en/manual/table-management-server-script)" you want to debug, then save it. 1. Open the "[Table](/en/manual/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"><ul><li><a href="/en/manual/table">Table Function</a><span>08.13.2024 up</span></li></ul></article> <ul><li><a href="/en/manual/table-management-server-script">Table Management: Server Script</a><span>08.13.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.