Code Service Tutorial

Create

Click “+ Add Code” from the to open the “Create New Service or Library” modal.

New Code Service

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.

New Code Service

Code Editor

  1. Add code to the window to run
  2. 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
  3. Edit test parameters
  4. Save and Test code and the results will then appear
  5. Turn the log toggle on to keep track of the code results

Debugging

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.

Trigger Pane

Add Trigger

Click on “+ Add Trigger”

Enter a name, source, and action and click “Create Trigger”. See Trigger Source for a list of sources and actions.

Update Trigger

There is only a couple of items that can be edited on the trigger. They will show up in the bottom of the window.

Click “Update Trigger” after making the edit

Delete Trigger

Click “Delete” on the right of the trigger and click “confirm” when prompted.

Timers Pane

Add the timer information and click “Create Timer” when you are finished

Click on the timer to make updates (you cannot update the name). Make sure to save changes by clicking “Update Timer” in the window.

To delete, click on “Delete” on the right of the timer.

Delete, Discard, and Save

  1. Click “Delete Service” and a prompt will appear to verify deletion.

  2. Click “Discard Changes” to delete changes you made in the session. It will take you back to the homepage without a confirmation prompt.

  3. Click “Save” to save changes made to the service.

Libraries

Add new library

Click “+ Add Code” from the to open the “Create New Service or Library” modal.

New Code Service

Switch to the “Library” button . Give the library a one word name or the system to refer to and a description and click Create. New Library

Library Code Page

Just like code services, you can write your own code. The difference is you can turn it in to a library to be able to use in code services.

New Library You can also add other libraries to your library. Note: Do not add the current library to itself.

Library Appearance

Your new code library will appear at the top in bold in your code service library list.

New Library

Each library is “required” from a service itself. Some libraries are not listed by default and need to be added. Libraries that are added later in the list will override earlier ones if they have conflicts.