It is simple to call a stored procedure through a RESTful API call if you have Catalina’s API for Dynamics SL. You can call any stored procedure and pass parameters and retrieve data.
This is a demo on how to call a stored procedure using Postman and Catalina’s API for Dynamics SL.
First, to do this demo, you need to download and install Postman. Postman is a developer tool that allows you to interact with API’s easily so that you can test API calls to see how you call them and what data is returned. You can get Postman here: https://www.postman.com/
In the demo, we are going to call the stored procedure SOHeader_all. This stored procedure retrieves all Sales Order Headers (SOHeader) for a particular CpnyID and OrdNbr. NOTE: this is just an example. With Catalina’s API, you can call any stored procedure.
SOHeader_all has 2 parameters: – @parm1: This parameter is for the CpnyID – @parm2: This parameter is for the OrdNbr (can use a wildcard like ‘O000%’ which will bring back all orders that start with O000.
You can see what the procedure looks like here:
@parm1 varchar( 10 ),
@parm2 varchar( 15 )
WHERE CpnyID = @parm1
AND OrdNbr LIKE @parm2
ORDER BY CpnyID,
So, if you wanted to retrieve all orders that started with “O000” for CpnyID = “0060” you would call the stored procedure like this:
exec SOHeader_all @parm1='0060', @parm2='O000%'
So, now how to call this using Postman through Catalina’s API for SL?
First you need to know where your Catalina API is installed. I am going to use the server name yourserver.com as the domain name. So, for this example, we would look at the endpoint as the following:
As you can see above, you would replace yourServer.com with wherever your server is. And you can see <ProcedureName> in the URL. this would be replaced with the actual stored procedure name you want to call (in this example, we are going to replace it with SOHeader_all). So, the new URL for the endpoint would look like the following:
In Postman, you would make it look like below. NOTE: when calling a customSQL stored procedure, you must use the action type of “POST”
Next, you need to set the authentication. This is done on the “Authorization” tab. Catalina’s API uses “Basic Auth”. So, make sure that you set the type for “Basic Auth” in the dropdown. And then enter the username and password that was given to you from your installer.
After that, you will have been given a SiteID from your installer. You will need to create a Header for that SiteID. You do this on the headers tab. You should enter that SiteID (in my example it is “DEFAULT”, but you would use the SiteID given to you by your installer) and the default CpnyID (in my example that is “0060”, but you would use your CpnyID of your database)
Finally, you will want to enter the body of the parameters that are being passed. There are 2 parameters for SOHeader_all (@parm1 and @parm2). The format of the body that you would set is below.
Catalina’s SLQuickPay is a way to send a request for payment to your customer as an email with a link to click to pay. Your customer simply clicks on it and pays (no need for a portal login or anything). The payment works through a PCI compliant payment processor and is automatically integrated back into Dynamic SL’s AR.
There are many ways to create SLQuickPay links. One of which is calling a stored procedure by passing a few parameters.
The stored procedure is called: xct_spSLPaddInvoicePaymentRequest
The parameters to this proc is:
@batNbr: The batch number of the invoice you want to send
@refNbr: The invoice number you want to send
@CustID: The customer who the link is going to be going to
@paymentEmailList: A delimited list of email addresses the link will be sent to
@siteID: (optional) For which configuration site to use (defaults to ‘SLPAY’)
@setupID: (optional) The PayFabric setupID you are to send. If not passed, the default will be used from SLQuickPay’s configuration
@deviceID: (optional) The PayFabric deviceID you are to send. If not passed, the default will be used from SLQuickPay’s configuration
You can call this stored procedure from most anything. You could call it from a trigger when an invoice is created. You can call it from a SL screen. Or even another application all together (like maybe excel that has a list of invoices to send)
Here is an example of how I added a button on the Invoice and Memo screen to send a SLQuickPay Link for a particular invoice.
Below, you can see where I created a button “Send SLQuickLink” that will take the current invoice on the screen and send a payment request link to the customer.
Below is the code behind the click event of the button. This will look at the current batNbr, refNbr (invoice number), custID, and get the email tied to the customer to send the link to that customer’s email.
Private Sub bPayLink_Click()
Dim SQLStr As String
Dim Csr_temp As Integer
Dim sCustID As String
Dim recfound As Integer
Dim maintflg As Integer
sCustID = GetObjectValue("ccustid")
SQLStr = "Customer_All " + SParm(sCustID)
serr = SqlFetch1(Csr_temp, SQLStr, bCustomer, LenB(bCustomer))
Dim lsSQL As String
Dim liCursor As Integer
lsSQL = "xct_spSLPaddInvoicePaymentRequest" & SParm(ThisScreen.cbatnbr.Text) & SParm(ThisScreen.crefnbr.Text) & SParm(ThisScreen.ccustid.Text) & SParm(bCustomer.EMailAddr) & SParm("SLPAY")
Call sql(liCursor, lsSQL)
MsgBox ("SLQuickLink Sent to CustID " + ThisScreen.ccustid.Text + " for invoice " + ThisScreen.crefnbr.Text)
Catalina has had a way to call custom stored procedures from their SOAP based web services for Dynamics SL for years. You can now do it using the RESTful API version.
Looking at the Swagger Documentation, you can now see a customSQL resource (If you don’t see this, contact Catalina Support to see about getting updated to the latest version of Catalina API for Dynamics SL)
NOTE: the checksum is a security feature that is turned on by default. This allows the API to double check to make sure that you are who you say you are. Use a SHA1 hash of the stored procedure name to generate the checksum.
The checksum requirement can be disabled in your DSLCONFIGFILE.xml file.
You can generate the checksum using any SHA1 library, or you can use the library included in our service distribution: /ctDynamicsSL/bin/ctStandardLib.dll
var checksum = ctStandardLib.ctHelper.getHash(siteKey, storedProcedureName);
If you use the Catalina Queue Engine for queuing records, you might want to retrieve data in a FIFO (First In First Out) method. This means you want to grab the oldest records first. This is easily accomplished by calling the Catalina Queue API with the parameter sortBy in the query string.
Example, if you are retrieving the queue ORDERS, you would format your URL, for the Queue API, like this:
If you are like me, you spend a lot of time in Microsoft SQL Server. Often, a trigger can cause you a lot of grief. Whether it is a recursive trigger that goes into an endless loop. Or a trigger that is updating data in the recordset that you are trying to save (causing problems in your client code).
Here is a quick way to get a list of all triggers in a particular DB
sysobjects.name AS trigger_name
,USER_NAME(sysobjects.uid) AS trigger_owner
,s.name AS table_schema
,OBJECT_NAME(parent_obj) AS table_name
,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate
,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete
,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert
,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter
,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof
,OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') AS [disabled]
FROM sysobjects WITH(NOLOCK)
INNER JOIN sys.tables t WITH(NOLOCK)
ON sysobjects.parent_obj = t.object_id
INNER JOIN sys.schemas s WITH(NOLOCK)
ON t.schema_id = s.schema_id
WHERE sysobjects.type = 'TR'
You will get a result like this that will list out the triggers and which tables they are tied to.