Skip to content

logicappsio/JsScriptingAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript API

Deploy to Azure

Deploying

Click the "Deploy to Azure" button above. You can create new resources or reference existing ones (resource group, gateway, service plan, etc.) Site Name and Gateway must be unique URL hostnames. The deployment script will deploy the following:

  • Resource Group (optional)
  • Service Plan (if you don't reference exisiting one)
  • Gateway (if you don't reference existing one)
  • API App (JavaScriptAPI)
  • API App Host (this is the site behind the api app that this github code deploys to)

API Documentation

The API app has one action - Execute Script - which returns a single "Result" parameter.

The action has three input parameters:

Input Description
Script JavaScript syntax
Context Object (optional) Objects to reference in the script. Can pass in multiple objects, but base must be a single Object { .. }.

Context Object Structure

{ "object1": { ... }, "object2": "value" }

In script could then reference object1 and object2 - both passed in as a JToken.

###Trigger### You can use the JavaScript API as a trigger. It takes a single input of "expression" and will trigger the logic app (and pass result) whenever the script returns anything but false. You set the frequency in which the script runs.

Example

Step Info
Action Execute Script
Script return message;
Context Object {"message": {"Hello": "World"}}
Output {"Hello": "World"}

You can also perform more complex scripts like the following:

####Context Object####

{ "tax": 0.06, "orders": [{"order": "order1", "subtotal": 100}] }

Script

return orders.map(function(obj){obj.total = obj.subtotal * (1 + tax); return obj;});

Result

[ {"order": "order1", "subtotal": 100, "total": 106.0 } ]

About

Javascript Scripting API - run javascript within your Logic App

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published