Creating a new Code Service
Click “+ Add Code” from the to open the “Create New Service or Library” modal.
This allows you to use the code libraries to build code. Give the code service a one word name for the system to refer to and click Create.
- Add code to the window to run
- Pick code libraries to use in your code (log is added by default). Make sure to choose the clearblade library to interact with the ClearBlade platform
- Edit test parameters then Save and Test code
- Test results will then appear
- Turn the log toggle on to keep track of the code results
To debug your code service, ClearBlade provides as simple, but flexible logging facility
1. Make sure the log toggle is on
2. When you create/edit your code service, you can embed log() calls in strategic places to monitor execution progress
3. You can then run/test the code service. This window should pop up after the service executes:
4. There will be a list of logs starting with the most recent one to go back to
5. Finally, when you have finished you debugging and your service is working perfectly, You can turn off logging by switching the toggle.You do not have to remove the logs from the code. They just become noop statements.
Select roles that should be able to run the code service
“Run as a user”- will let the developer user see what the end user see
“Concurrency”-limits how many instances that can run at the same time
“Execution timeout”-limits how long the code service execution can run
“Auto restart”- restart service automatically if there is a crash
“Currently running”-shows what code is running and can be refreshed.
Click on “+ Add Trigger”
Enter a name, source, and action and click “Create Trigger”
There is only a couple of items that can be edited on the trigger.
Click “Update Trigger” after making the edit
Click “Delete” on the right of the trigger and click “confirm” when prompted.
“Name”- add a label to the timer
“Start Date”-add a date and time to start the run
“Run”- select how many times the code should run
“Description”- provide a description for the timer
Click “Create Timer” when you are finished
Click “Update Timer” to make updates (except name) and “Delete” to delete timer.
If a run fails, a banner will show. If you click on “view” on the banner to see what failed.
Delete, Discard, and Save
Click “Delete Service” and a prompt will appear to verify deletion.
Click “Discard Changes” to delete changes you made in the session. It will take you back to the homepage without a confirmation prompt.
Click “Save” to save changes made to the service.