Running stored procedures
Note: This topic applies to only on-premises environments.
         TaskMan can execute stored procedures directly, without going through the IDO layer. To do this, TaskMan bundles the stored procedure in a transaction.
The following example shows the steps to set up a stored procedure that runs through TaskMan from a form:
- 
            Use the Background Task
                  Definition form to set up a record of type SP with the name of the stored procedure as the task name. 
            For example, create a task called AddProcessErrorLogSp, of type SP. 
- 
            Add a button to a form. Name the button TestSP and assign sTest as the caption. 
            This button will be used to run the stored procedure. 
- 
            On the Components property sheet for the button, create an event
               named RunSp: 
            - Click Events (appears as a yellow lightning bolt on the component properties sheet).
- Click Primary, and then click the associated ellipses (...) button.
- In the Event Handlers dialog, click New.
- 
                  In the Event Handler
                        Properties dialog, set these values: 
                  - Event
- Specify RunSP.
- Description
- Enter an optional description or leave blank.
- Type
- Run Background Task.
 
- 
                  For the parameters, click Parms, and then click the ellipses
                        (...) button. In
                     the Event Handler Parms dialog, specify
                     this information: 
                  - Error Message
- Specify mBackendMessage.
- Success Message
- Specify sSubmitted.
 
- 
                  Click Type
                        Specific Parameters. In the Edit
                        Background Task Name and Parms dialog, specify this information: 
                  - Task Name
- Specify AddProcessErrorLogSp.
- Task Parms
- Specify BG~TASKID~,FV(TestMessage).
 The FV keyword tells SyteLine to enclose the value of TestMessage in single quotes. The BG~TASKID~ substitution keyword is replaced at run time with the task number. For a complete list of keywords, see TaskMan substitution keywords. 
- Click OK repeatedly until you return to the form.
- Verify that RunSP is the primary event for the TestSP button.
- Save the form.
 
- Add an Edit box to the form with a variable called TestMessage as the data source.
- Save the form.
- 
            Enter a message in the TestMessage edit box, and submit the task. 
            The system displays a message that says: Submitted.
- Open the Background Task History form. When the task completes, the test message displays in the event log.