Back to User Guide

How embeddable functions work in Raytha


Learn how to write business logic code right inside the Raytha portal.

Raytha Functions are a way to write custom code in the administrator portal of Raytha to add functionality to your application. Use cases for this include but are not limited to:

  • Create your own custom api endpoints
  • Accept form submissions and save response
  • Send an email out of the platform
  • Make an external HTTP call and return and/or save result
  • [Coming Soon] Webhooks trigger functionality
  • [Coming Soon] Timer trigger functionality

In a way, it is effectively writing "code behind" directly into the platform. This does require experience writing Javascript if you are interested in extending Raytha's functionality.

Writing code behind

When you write code for a Raytha Function there are few items you need to be aware of.

  • Write your code in javascript. The code is compiled and run using Microsoft's ClearScript engine which works with V8 implementation of javascript. This gives you access to basic engine javascript. 
  • Triggers. Functions are triggered by some action. You select the trigger type when you create the function.
  • Built-in objects. The javascript by itself would not be of much use if you did not have layer of access to the database and other core functionality.

Add a function

To get started, make sure you have Manage System permission and click Functions in the left side navigation and then click Add function.



Triggers

Raytha Functions are triggered by some action. You select the trigger type when you create the function.




Triggers come with boilerplate code that the ClearScript engine runs when necessary. Click the link below to learn how to write code for each trigger type.


Built-in Objects

To provide valuable functionality to you while you write Raytha Functions, the following objects are included in the ClearScript engine that you can call.

  • API_V1
  • CurrentOrganization
  • CurrentUser
  • Emailer
  • HttpClient

Learn how to make use of these objects.



Continue learning