Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On a per form basis, you can write SQL transactions that run on submission.  Use this functionality create unique ID's that can be bound to the transaction (Requsition ID, Expense Report ID, etc.), or to save data from the submission to a SQL Data source.  Create a web form that captures any data of interest. 

In this example, inputs for you will enter a First Name and Last Name on an Employee Resource are laid out in the form designer.

Image Removed

With the form created, click the Form Actions tab and choose SQL Query from the Select an Action drop down.  Click the Add Action button to configure the Action.

Image Removed

Give the Action a descriptive Title.  If you have multiple Actions, it is helpful to be able to easily identify them for maintenance and support.  In the SQL Server Type drop down, choose Microsoft SQL Server.  In the Query box, you can type a SQL statement to execute.  In this example, First Name and Last Name are inserted into an Employees table.  The table includes an auto-incrementing Identity column that will be used as an employee ID.  The script to create that table is below for reference:

Code Block
languagesql
titleEmployees Table Create Script
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Employees](
	[ID] [int] IDENTITY(10001,1) NOT NULL,
	[FirstName] [varchar](150) NULL,
	[LastName] [varchar](150) NULL,
 CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

Create a web form that captures any data of interest.  In this example, inputs for First Name and Last Name on an Employee Resource are laid out in the form designer.  Be sure to make note of the API Property Name for each Form Component.  In this example, the component names are simply firstName and lastName.

Image Added

With the form created, click the Form Actions tab and choose SQL Query from the Select an Action drop down.  Click the Add Action button to configure the Action.

Image Added

Give the Action a descriptive Title.  If you have multiple Actions, it is helpful to be able to easily identify them for maintenance and support.  In the SQL Server Type drop down, choose Microsoft SQL Server.  In the Query box, you can type a SQL statement to execute.  Using the table defined above, you can insert into the table with the following script:

Code Block
languagesql
titleSQL Insert
insert into Employees (FirstName, LastName) VALUES ('{{ data.firstName }}','{{ data.lastName }}');

A few things to note about the insert into Employees:

  1. You do not need to insert data into the ID column.  This column is an Identity column and any insert will automatically calculate the value of this column.

  2. The value inserted into the identify column is mappable in the GlobalForms mapping utility.  This allows you to leverage this data in a GlobalCapture workflow if desired.  For example, in a PO example, you may wish to send an email to the form submitter notifying them of the PO for their request.  

  3. Data from the form is accessible in the SQL Statement and is accessed using the data variable, as is the case in most rules in the GlobalForms application.  Wrapping the variables in Handlebars {{ }} allows GlobalForms to discern between a literal string you are looking to insert and data entered into the form.