Scripts
Create, manage and run C# scripts
The Interface

Basics
Scripting module allows to write code in C# programming language. This allows to extend CredoID functionality adding new possibilities that wouldn't be available out of the box.
CredoID uses C# programming language and Monaco Editor for scripting.
The Monaco Editor is the code editor that powers VS Code.It is licensed under the MIT License and supports Edge, Chrome, Firefox, Safari and Opera. The Monaco editor is not supported in mobile browsers or mobile web frameworks.
CredoID Version 4.5.0 and up no longer supports scripts written in IronPython
Creating new script
Click on "Add" to create new script.

- Add - Opens script configuration menu.
- Delete - Deletes selected script.
- State - Shows scripts state, it's either “Stopped” or “Running”. Also it acts as a button to pause a script.
Fill in necessary fields in the right side of details window.

- Name - Script name must be non empty string and contain only alphanumeric characters. Please note it cannot contain empty spaces.
- Description - Short description of a script.
- Launch on startup - If checked - script will be launched automatically when CredoID is started.

This section contains source code of the script and editor with highlights.
▶ - Run the script.
◼ - Stop the script.

This section displays console output window.
Scripting examples
Feel free to use our examples as base for improving or writing your own scripts. Written using C#. Source code can be found in our repository.
User monitor
This script shows latest access event with user picture if it is available in a simple form.

Download Users_monitor.zip
To run the script, extract files and:
- Create script with code from downloaded zip file.
- Add "index.html" file to
C:\\ProgramData\\Midpoint-Security\\CredoID Service\\Files\\Scripts\\*_script_name_*. - Run the script and open browser at
http://localhost:8000.
Parking occupancy management
This script allows to manage parking space limits for companies using access levels.

Create a script and name it "parking". Open and copy content of script.cs into script content field, hit Save and Run.
Download parking.zip and extract content under %ProgramData%/CredoID Service/Files/Scripts/parking/static (directory should already exist if script was run before).
You should be able to access parking occupancy web interface via http://localhost:8090/scripting/parking/static/
To select occupancy access level and entry/exit readers - click settings icon in the top right corner.
Access level use limit
This script allows to limit entry count incorporating schedules and doors. For example: users can enter specified doors at certain schedule only once per 24 hours until their access levels is reset.
Open and copy script code from alsresetscript.cs
There are some lines that must be edited to set schedule range, access level names, door names and access level reset time.
Comments with explanations are left inside the code.