Functions are invoked as POST restful requests. The json payload map is passed as a parameter "v". The user context is also and always passed as an implicit parameter.
Let's see an example of such function where "payroll" value is utilized from body of the request "v" and return an object "m" representing an insurance quote.
m = new HashMap(); payroll = v.payroll; annual = payroll * 0.0142; monthly = (annual * 1.05) / 12; m.annualPremium = Math.floor(annual * 100) / 100; m.monthlyPremium = Math.floor(monthly * 100) / 100;; m.annualPaymentSaving = Math.floor((m.monthlyPremium * 12 - m.annualPremium) * 100) /100; m;