EspaƱol
English (Deprecated)
IntroductionFirst stepsAdmin toolFormsLists of valuesFunctionsSecurityReportsWeb packagesWeb linksAutoMLDashboardsIAMSettingsAdmin tasksAPI referenceHow to'sMaster-detail relationshipsFree-text searchCalculated fieldsWorkflow tasksSending emailsAccessing database from functionsCustom reportsAPI consuming from web appsFAQ
How to's
Master-detail relationships
TBW (To be written)
Free-text search
TBW (To be written)
Calculated fields
TBW (To be written)
Workflow tasks
TBW (To be written)
Sending emails
In order to send an email, you can develop a function and assign an action to trigger the sending of the email.
Create a function with the following parameters:
Field | Description | Value |
---|---|---|
Name of the application | The name of the application that owns the function. | "Demo" |
Name of the function | The function name. | "sendEmail" |
Language | Programming language used to write the function. Let's choose JavaScript. | "ECMAScript on JVM (Nashorn)" |
Function code | Function source code in the selected programming language. | (See in the following table) |
var System = Java.type('java.lang.System');var Properties = Java.type('java.util.Properties');var Message = Java.type('javax.mail.Message');var PasswordAuthentication = Java.type('javax.mail.PasswordAuthentication');var Session = Java.type('javax.mail.Session');var Transport = Java.type('javax.mail.Transport');var InternetAddress = Java.type('javax.mail.internet.InternetAddress');var MimeMessage = Java.type('javax.mail.internet.MimeMessage');var Authenticator = Java.type('javax.mail.Authenticator');var properties = new Properties();properties.put("mail.smtp.auth", "true");properties.put("mail.smtp.host", "smtp.gmail.com");// SSL (si se desea utilizar SSL, que es la alternativa recomendada por Google)properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");properties.put("mail.smtp.socketFactory.port", "465");properties.put("mail.smtp.port", "465");// TLS (si se desea utilizar TLS)//properties.put("mail.smtp.starttls.enable", "true");//properties.put("mail.smtp.port", "587");var authenticator = new Authenticator() {getPasswordAuthentication: function() {return new PasswordAuthentication("usuario@gmail.com", "*********");}}var session = Session.getInstance(properties, authenticator);var message = new MimeMessage(session);message.setFrom(new InternetAddress("usuario@gmail.com"));message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("example@acme.com"));message.setSubject("Test");message.setText("This is just a test.");Transport.send(message);System.out.println("OK");
Let's create the action that will trigger the function for sending the email.
Field | Description | Value |
---|---|---|
Form | Name of the form to which the function will be asociated. | "Demo, Customer" |
Name of the action | Name of the action. | "sendEmail" |
Moment | Moment when the action will be triggered. | "AFTER" |
Events | Events which the action will be asociated to. | {"INSERT", "UPDATE"} |
Granularity | Indicate if action will be executed once per affected row or per affected statement. | "ROW" |
Function | Function that will be executed. | "Demo, sendMail" |
Condition | Condition that must be met in order to execute the action (optional). |
Now, everytime that a customer is inserted or updated, an email will be sent.
Accessing database from functions
Custom reports
API consuming from web apps
const query ='{' +' categories: Demo_CategoryList {' +' id' +' code' +' name' +' }' +'}';const variables = {authorization: "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImRlbW8iLCJzdXBlciI6ZmFsc2V9.B1wchXyT_ToymZSAOvnHJZbnHYXh-KE_6bliwUzrCBY"};let request = JSON.stringify({query: query, variables: variables});fetch("https://demo.flows.ninja/graphql", {method: "POST",body: request}).then(response => response.json()).then(json => {let categoryList = json.data["categories"].map(item => { return {id: item.id,name: item.code,title: item.name,}});this.push("categories", ...categoryList);});
const query ='{' +' categories: Demo_CategoryList(' +' where: {' +' code: {EQ: "' + category.name + '"}' +' }' +' ) {' +' id' +' code' +' products: ProductListViaCategory {' +' id' +' code' +' name' +' price' +' description' +' }' +' }' +'}';const variables = {authorization: "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImRlbW8iLCJzdXBlciI6ZmFsc2V9.B1wchXyT_ToymZSAOvnHJZbnHYXh-KE_6bliwUzrCBY"};let request = JSON.stringify({query: query, variables: variables});fetch("https://demo.flows.ninja/graphql", {method: "POST",body: request}).then(response => response.json()).then(json => {let itemList = json.data["categories"][0].products.map(item => { return {id: item.id,name: item.code,title: item.name,category: json.data["categories"][0].code,price: item.price,description: item.description,}});this.set('category.items', itemList);});