Custom Alerts

    gsiQandA

    Jimmy Morales, Consultant

    Q and A

     Question:  Alerts and Notifications are limited in OpenAir; what if I want emails different than what OpenAir offers by default?

    Answer:  You can leverage OpenAir scripting to create custom emails for virtually anything in OpenAir!

    Using the Scripting Reference Card available on OpenAir.com, you can build custom scripts that allow you to send up to 3 different emails in a form, or 100 scheduled emails with 30,000 characters each.

    Creating a basic email alert through scripting is easy:

    1. Create a new Form Script (in this example, Expense Report)
    2. OpenAir defaults a basic function for you to use in the Scripting Editor:
      1. Q and A 2
    3. We will remove “type” as it does not apply here. Insert your variables to build the conditions for the alert:
      1. Q and A 3
    4. Insert the conditions to send the alert:
      1. Q and A 4
    5. Define the message using a variable:
      1. Q and A 5
      2. Note: you can use “+var” [where “var” is the defined variable] to append variables to the body. For example, the body line could read:
        1. “Alert: Someone named” +username +”expensed a personal item.”,
      3. Call the NSOA.meta function to send the alert in the function:
        1. Q and A 6
      4. Your final script should look like this:

    function main() {

            var notes = NSOA.form.getValue(‘notes’);

       

        if (notes == 'Just for fun!'){

           

            var msg = {

                to: ["myaddress@example.com"],

                cc: [],

                bcc: ["external@example.com"],

                subject: "ALERT: Someone expensed a personal item.",

                body: "Hello, a user has expensed a personal item.",

                author: 37

                  };

     

            NSOA.meta.sendMail(msg);   

        }

       

    }

    1. After you define which function to execute and under what circumstance (In this example: After clicking “Save” on an Expense Report, but just before the form is saved, Execute the function called main)
      1. Q and A 7
    2. Deploy your script and if the criteria matches your conditions:
    3. Q and A 8
    4. You should receive an email:
      1. Q and A 9