How to Create and Connect a Business Process in Autorun
This guide shows the exact steps to create and connect a Business Process in an Autorun application.
Super Fast Build: Prompt for Mileva
When a new Invoice record is created, send an email notification to the assigned sales rep and account manager with Invoice details (number, amount, customer, due date).
Steps:
1. Open Process Designer
- Open Process Designer in Developer Toolbox
- Click Add process
2. Create a New Process
Fill in the basic process details:
- Name (visible in the upper left corner with edit button): A Test Business Function
- Type: Business
3. Configure the Trigger
In the Trigger section set:
- Select from the Event dropdown menu: After Create
- Select from the Entity dropdown menu: Offers
This means the process will run every time a new Offer record is created.
A process with no event selected never runs on its own. It waits to be started manually or through a route. See Business Function Props for every available event.
4. Build the Process Flow
On the canvas:
- The Start and End nodes are created automatically
- From the Library section, drag and drop a Code block of your choosing
- Connect the nodes by draging one end of the node to the other:
Start -> CodeCode -> End
If Start and End are not connected, the process will not execute.
Nodes run one after another, each following its first outgoing connection. Branching is not supported — a node with two outgoing connections still only follows one of them. Express conditional logic with if statements inside a Code block instead of by drawing two paths.
5. Add Logic to the Code Block
-
Click Code icon in the upper right corner of the code
-
Your logic is added by default, for example:
console.log(context);
- Click Save
Writing the code
Everything the process can do is reached through context. The record that triggered the run is on context.record, and the server-side function library is on context.functions.
// Runs after an Offer is created
const offer = context.record;
log("New offer " + offer.ID + " for " + offer.Amount);
const client = await context.functions.getById("clients", offer.ClientId);
if (!client) throw new Error("Offer " + offer.ID + " has no valid client");
const sent = await context.functions.SendEmailAsync(
client.Email,
"We have received your offer request",
"<p>Thank you. Your offer <strong>#" + offer.ID + "</strong> is being prepared.</p>",
null
);
if (!sent) console.error("Confirmation email to " + client.Email + " failed");Three things to know before your first process:
- Every business function is asynchronous and must be
awaited. - Most of them do not throw when they fail.
create,update, anddeletereturn{ success, message };httpreturns{ ok }; email and notification functions return a boolean. Check the result, or the process will carry on as though the step had worked. console.logandlogboth write to your application log, which is where you check what a process actually did.
The full library is documented in the Business Functions Reference.
Testing the process
Use Run in the designer to execute the process on demand. A manual run starts with an empty context.record unless you supply a body, so guard against missing data when a process can be both triggered and run by hand:
const record = context.record || {};
if (!record.ID) {
log("No record supplied — nothing to do");
return;
}Then check your application log to confirm what happened. A process that appears to do nothing has almost always hit an unchecked failure result rather than a crash.