> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/server-side-script.md).

# Server-side Script

## Description

This part allows you to create server-side scripts in Lua. The LogicNets runtime provides a set of APIs for database access, context manipulation, string manipulation, and other actions. The exact list of APIs and the documentation and examples can be found using the link shown in the part editor.

## Use

This part allows you to create server-side scripts in the Lua programming language.

## Editor Fields

| Field Name | Description/Use                   | Type/Options | Optional/Mandatory |
| ---------- | --------------------------------- | ------------ | ------------------ |
| Lua Script | Allows you to create Lua scripts. | Script       | Mandatory          |

## Code Validator

In LogicNets v7.4.6+, you can have the system validate scripts against the Lua code syntax using the code check feature. After completing your script, click ***Check Code*** to receive warning and error messages against Lua version 4 or version 5 or both. The system shows error messages and the Lua-script line number.

### Mode

There are 3 modes that you can choose from depending on which LogicNets version you are on: Lua4, Lua5, or Mixed. *Mixed* checks both for Lua4 and Lua5 errors and warnings. You can change the mode of the code validator in the *System Configuration* function on the *Designer* tab.

### API Help

Click this link to open an HTML file with Lua code syntax help and examples.

### Message

Messages show where the warning or error comes from within the code checker. There are four different message that the code validator can show.

* **Luacheck:** This message gets displayed when there are warnings and errors found by the Luacheck code static analyzer tool. See the following link for documentation of the errors and warnings that luacheck can display: <https://luacheck.readthedocs.io/en/stable/warnings.html>
* **Lua5 compiler:** This message means that the Lua5 compiler cannot compile the code in the script, and the system cannot execute the code in the script in Lua5. The system will crash instead. LogicNets introduced Lua5 in v8.0, so if you see these errors in version 7.x your code will still run since it uses the Lua4 compiler.
* **Lua4 compiler:** This message means that the Lua4 compiler cannot compile the code in the script, and the system cannot execute the code in the script in Lua4. The system will crash instead. All LogicNets releases prior to v8.0 use the Lua4 compiler.
* **Lncheck:** These are LogicNets code checks that will output warnings and errors if it detects faulty code in the script.

### Warning Codes and Messages

The following table lists warning codes and associated messages.

| Code   | Message                                                                                                         |
| ------ | --------------------------------------------------------------------------------------------------------------- |
| (W114) | Accessing global variable ‘’                                                                                    |
| (W910) | Global ‘' accessed, add to local alias list: 'local = ’                                                         |
| (W921) | Missing global for ‘’                                                                                           |
| (W922) | Unrecognized global found ‘’                                                                                    |
| (W923) | Incorrect alias: found ‘', expected ‘\<expected\_alias>'                                                        |
| (W924) | Incorrect module alias: found ‘', expected ‘\<module\_alias>' or ‘\<module\_alias\_short>’W932: Lua4 varargs in |
| (W932) | Lua4 varargs in:                                                                                                |
| (W933) | Possible upvalue in:                                                                                            |
| (W934) | Double dummies in:                                                                                              |
| (W935) | gsub usage in:                                                                                                  |

**Error Codes and Messages**

| Code   | Message                                                           |
| ------ | ----------------------------------------------------------------- |
| (E911) | '' is a LUA-4 global, use alternative as alias: 'local = ’        |
| (E912) | '' is a Runtime-4 global, require module: ‘..’ and use ‘..'       |
| (E913) | '' is a LUA-4 global, look for an alternativeE925: Lua 5 compiler |
| (E930) | suspected for...in loop in:                                       |
| (E931) | Lua4 getn/strlen calls in:                                        |

### Save and Validate

When pressing the save button it might say “*x warning(s) found. Please start project-validation*”. This means that the code validator found an error or warning within your Lua script. To see the error run the code validator by pressing the “check code” button

## Configuration Options

It is possible to extend the list of APIs with custom APIs when you have access to the server that is hosting your installation. More information can be found in the topic on [Custom Parts](/release-9/platform-documentation/advanced-topics/custom-parts-workers-scripts-and-libraries/custom-parts-workers-scripts-and-libraries.md).

## Example

Please see the [example project](/release-9/example-gallery/example-projects-for-parts/server-side-script-example-project.md) here.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/server-side-script.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
