What is a Scriptable Function?
Scriptable Functions is our middleware platform, which allows developers to customise Layer functionality with code, unlocking unlimited potential for extending the system. Functions work well for integrations with third-party systems, or simply for modifying or supplementing the control flow of existing Layer processes.
What's more, you can add buttons to select places in the UI, in the form of menus + tabs, in order to display data from third party systems.
With that in mind, you don't have to be a developer to work on these! We recently launched Function Templates, which means you can select from a pre-defined template, fill in some settings, and assign this to your record type.
Some sample uses of Functions are:
Send a custom e-mail when a sales order is raised 📩
Transmit orders to a provisioning system once paid 📃
Send a case rating & review to a third party system ⭐
Update values in a record based on custom rules 🛣
Create workflow rules to perform actions based on triggers 🔫
Relay data from one API to another 🚟
The scope of Functions is only limited by your imagination, and the functionality available on the APIs you're getting the data from, and posting to.
How can they help my organisation?
In other CRM systems, administrators would need to employ expensive developers to make basic customisations to their setup, but using our middleware, organisations can unlock the ability to write custom code snippets to carry out tasks without involving third-party developers.
How can I use them?
The process of creating a good Function is as follows:
Plan It 🖋 - What do you want the function to do?
Code It 💻 - Spin up a new function, and test it out
Map It 🔗 - Associate the function with an invocation method, as outlined below
How do I implement them with existing system objects?
There are three ways to invoke Functions on the system:
Mappings - When something happens, e.g. a lead is created, or a sales order is updated
Buttons - Strategically placed buttons to help you perform an action
Web Hooks - Invoke functions from your third party system on-demand
Scheduler - Run functions at a predetermined day and time. This is a premium feature - please check this article for more information on how it works.
With the concepts out of the way, let's dive into some more detail.
How do I build a Function?
Customise a pre-built extension - Select from a pre-built library of extensions, and plug in settings specific to your use case. If you use this, you'll be able to customise properties, but not edit the extension unless you make a copy.
Where to start?
Firstly, create your new function, and set it to Code from scratch mode.
Next, we need to select an execution method. This part's really important and determines whether your script runs straight away, or is launched into the background for processing when resources are available.
Check Run Synchronously if you want to block any further operations until your script has completed.
This is useful for operations that need to be completed immediately. If you don't mind your script running in the background (e.g. it doesn't affect any UI operations), then you can leave this de-selected.
What's in a signature?
Once you're directed over to the main editor, you'll notice a section on the left called "Default Signature"
Signature properties are the default properties that are passed in to a function when executed by default.
Having access to these means you can address the given type, get more details on it, and code up your function accordingly. e.g., if you're passed a quotation Id, you can look this up from the API using ScriptableFunctionHttpRequest, as outlined below.
We've made an extension library which contains some useful functions which abstract some of the complexity of coding for some basic functions like sending system emails, or calculating rate tables.
You can read more about extensions here.
Layer managed templates can be loaded in order to help you get started, or form a basis of a managed integration (e.g. billing or third party).
In order to ensure that when an integration or template changes, it doesn't break your integration, we sometimes lock these scripts to prevent you from making a copy.
When using a template, it's really easy to set this up for your company! We add in snippets, which you can replace via the UI.
Coming soon: you'll be able to include other files to the top of your LayerScript, e.g. key stores.
Invoke LayerScript® by API
Coming soon: you can invoke Functions by API, at this endpoint:
Check out this guide on how to test Functions
Need more help?
Contact us via Intercom to ask questions about Functions.
We don't currently offer support on non-Layer managed extensions, but can certainly point you in the right direction.