Welcome Guest.  • Login

AgriData Inc. Docs


Search the wiki

Certain companies may want to automatically email a copy of a form or a summary of certain aspects of the form to a specified email address either upon the save of a form or once a specific criteria within the form is met.

Attach shapefile, KML, and/or SatLoc Job file
> When emailing the current form (not a summary), the option also exists to include an ESRI shapefile, KML, or a SatLoc job file within the "Attach" segment of the formula.

The Forms Designer in Surety Pro provides a script to do either action or even both actions if desired.

Email This Form

First lets go over how to email an exact copy (in PDF format) of the filled out form once "Save Form" is clicked.

With the desired form template open within Surety Pro's Forms Designer, create a control such as a text box or label and place it off of the printable canvas.


Then lets type in our equals sign "=" into that control Text property.


The script we are going to be using is located in the Insert drop down > EPIC Scripts > emailThisForm (Action)


The script that appears is just used as a guide to show you what is necessary to assign in this action.

=emailThisForm("onSave", fromEmail, toEmail, subject, body,Attach:"SHP","KML","job")

We will need to add a few things to this script to get it to work.

Add the word "Event:" in front of emailThisForm
=Event:emailThisForm("onSave", fromEmail, toEmail, subject, body,Attach:"SHP","KML","job")

We can fill in the prompted items within the parentheses. If you are not referencing controls on the form, remember to surround your entries with quotations("").
Leave "OnSave" as it is. This is how the program will know when to send the email.

The fromEmail, can either reference a control on the form if it will contain an email address, or type in a manual address within quotations. I have chosen to type in a manual address since the email I want it sending from doesn't exist anywhere on the form at the current moment.

=Event:emailThisForm("onSave", "info@agridatainc.com", toEmail, subject, body,Attach:"SHP","KML","job")

The toEmail works the same way. This time, I will reference a control that is named SupervisorEmail within the form template so that it can be sent to a different person every time if needed.

=Event:emailThisForm("onSave", "info@agridatainc.com", SupervisorEmail, subject, body,Attach:"SHP","KML","job")

For the SupervisorEmail, I will also need to add that control to the form. I will simply add a textbox off of the printable canvas so the email address isn't included in pdfs and printed copies. 


Again, subject works in a similar fashion. Either type a manual subject to hard code something specific such as "Chemical Work Order Status" or reference a control to have the form dynamically assign the Email subject.

=Event:emailThisForm("onSave", "info@agridatainc.com", SupervisorEmail, ClientName, body,Attach:"SHP","KML","job")

The body is exactly the same as the Subject in terms of what can be set. This time I will reference the Control called "Status" in which case I do not need quotation marks.

=Event:emailThisForm("onSave", "info@agridatainc.com", SupervisorEmail, @clientName, Status,Attach:"SHP","KML","job")

The "Attach" section is used to also send a shapefile, kml, and/or  satloc job file with the form in the email. Leave the Attach:"SHP","KML","job" as-is to attach all files, otherwise simply delete the file types you don't want included. or remove everything including the word "Attach" in order to simply send the pdf.
  • If a Download Job function exists on the form, the attached Job file will use that value.
  • If a fieldId control exists within the form template, the attached zip file will use the fieldId attribute as its filename.

The last step (Optional) is to use an if statement after "Event:"
I will use a simple if statement that will activate the email if the Status is set to Complete (See: Forms Designer - Insert Variable for more information on if statements.)
This will assure that the email is only sent after a certain criteria is met, in this case, the Status change to Complete.

=Event:if(Status="Complete"){emailThisForm("onSave", "info@agridatainc.com", SupervisorEmail," Work order status for Field " + @fieldId,Status,Attach:"SHP","KML","job")}else{""}

Email Summary Form

Instead of emailing the entire form upon a save, there is also the option to Email a "Summary" of the Form that is being saved.

Before a summary can be emailed, it must be created.

We can do this by creating a new form. File > New Custom Form

Examples of what could be included on the Summary Form:

  • Client name
  • Form Name that was saved
  • Date
  • Field name
  • Crop Name
  • Map of submitted location


Keep in mind when referencing information that does not have a preset variable(@clientName, @fieldId, etc.) available, you must use the control referencing script in the Formula Editor to pull from the previously saved form(the one you are filling out). See: Forms Designer - Formula Editor

Once the summary form template is created, save and name it something that you will remember.


Once you have saved successfully saved your form, go back to the original Form layout and add a new Label control to the form.

into the Text area of the Label control properties then go up to Insert>EPIC Script > emailsummaryform (action)

This will add
emailSummaryForm("onSave", formName, fromEmail, toEmail, subject, body)

replace formname with the name of the Summary form that was created and surround it in quotations or tick marks.

replacefromEmail with whatever email address you want in the from Line and surround it with quotation or tick marks if you are not referencing a control on the form. We recommend using Services@agridatainc.com if you are having trouble with the emails getting caught in spam filters.

replace toEmail with the email address the summary is to be sent To and surround it with quotation or tick marks if you are not referencing a control on the form.

Finally replace the subject and body with whatever you want the email subject and body to be. Make sure that the text is surrounded in tick marks or quotations if you are not referencing a control on the form.
"Submitted Chemical Work Order Form"

I will setup the body to show the current status of the Chemical Form I am saving. body

The whole script should look something like this:
=Event:emailSummaryForm("onSave", "ChemicalEmailSummary", "services@agridatainc.com", "adam@agridatainc.com", Status)

with the script complete, Publish the Form

Now every time that particular form is Saved, an email will be sent with an attachment of summary form that was created. After hitting save, a message will pop up very quickly stating that the message is sending.


Here is how the email will look when it appears in your inbox


Change the sent email depending on certain items filled out within the form.

By using if statements the auto email scripts can change based on something such as a Status, Client, Crop or anything else that has been defined on the form.
See: Forms Designer - Insert Formulas

When using if statements the "Event:" string needs to come immediately after the "=" 

For Example:

=Event:if(Status="Complete"){emailThisForm("onSave", "services@agridatainccom", ApplicatorEmail, "Work Order Complete", ClientName,Attach:"SHP")}

Note: A separate control needs to be created for each of the "elseif's". For the example above, a new control and script would be created if a different status selected prompted an email to be sent to a different email address.

Still have questions?

AgriData, Inc. Support

Related Pages:

Contact AgriData, Inc Support
Phone: (701)746-8580