Tag: Quick Query

Tips/Tricks on using Catalina’s Quick Query API to get the data you want out of a SQL Server Database

The examples below are for the RESTful API version of the Catalina API for SL. If you want to see how you can do similar things in SOAP, you can see an older post here: https://catalinatechnology.wordpress.com/2017/02/06/example-of-building-a-form-client-to-use-the-catalina-quick-query-soap-web-service/

Paging Data

You can page content by passing a pageSize and a currentPageNumber.  The below example will retrieve page 5 with a page size of 10 items

{
"filters": [{
"name": "pageSize",
"value": "10",
"comparisonType": "="
},
{
"name": "currentPageNumber",
"value": "5",
"comparisonType": "="
}
]
}

What you will see with this is that in the table results, there will be several fields:

  • counter: this is the current record in the returnset
  • totalEntries: This will be the total number of records in the query
  • totalPages: this will be the total number of pages (given the pageSize)

This would then allow you to page through the results and not bring everything down at once.  Below is an example of those fields:

 {
"counter": 41,
"Account Number": "12313 ",
"Account Type": "1A",
"Active": 1,
"Class ID": "ASSETS ",
"Validate ID": " ",
"totalEntries": 338,
"totalPages": 34,
"errorMessage": null
},

Filtering Data

You can also limit records by adding additional filters that you can limit by fields.  Here is an example of bringing back all records with a Class ID = “ASSETS”

{
"filters":[
{
"name": "Class ID",
"value":"ASSETS",
"comparisonType":"="
}
]
}

If you wanted to bring back page 4, with a page size of 10, of items that have a Class ID = ‘ASSETS” and are flagged active, you would do this:

{
"filters": [{
"name": "pageSize",
"value": "10",
"comparisonType": "="
},
{
"name": "currentPageNumber",
"value": "4",
"comparisonType": "="
},
{
"name": "Class ID",
"value": "ASSETS",
"comparisonType": "="
},
{
"name": "Active",
"value": "1",
"comparisonType": "="
}
]
}

Some notes about comparisonType. These are the possible values (NOTE:  You can add as many comparisons as you want in your filters to get the results you need)

Type Description
= Equals
Example, if you wanted to retrieve all items with an Account Type equal to 1A, in QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Account Type”,
“value”: “1A”,
“comparisonType”: “=”
}]
}

Less than
Example, if you wanted to retrieve all items with a created date less than 1/2/2000, in QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Account Type”,
“value”: “1/2/2000”,
“comparisonType”: “<“
}]
}
Greater than
Example, if you wanted to retrieve all items with a created date greater than 1/2/2000, in QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Account Type”,
“value”: “1/2/2000”,
“comparisonType”: “>”
}]
}
>= Greater than or equal
Example, if you wanted to retrieve all items that were updated after or equal to 3/24/200, in QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Last Update Date”,
“value”: “3/24/2000”,
“comparisonType”: “>=”
}]
}
<= Less than or equal
Example, if you wanted to retrieve all items that were updated before or equal to 3/23/200, in QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Last Update Date”,
“value”: “3/23/2000”,
“comparisonType”: “<=”
}]
}
!= Not Equal
Example, if you don’t want active accounts returned from QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Active”,
“value”: “1”,
“comparisonType”: “!=”
}]
}
LIKE Like (or contains) – Uses % as a wildcard
Example: if you want to retrieve all account numbers that start with 103, from QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Account Number”,
“value”: “103%”,
“comparisonType”: “LIKE”
}]
}

IN Inside a comma delimited list
Example: if you want to retrieve just account 1030 and 1031 from QQ_Account, you would do the following:
{
“filters”: [{
“name”: “Account Number”,
“value”: “1030,1031”,
“comparisonType”: “IN”
}]
}
NOT IN Not in a comma delimited list
Example: if you want to exclude accounts 1110 and 1115 from QQ_Account, you would do the following:

{
“filters”: [{
“name”: “Account Number”,
“value”: “1110,1115”,
“comparisonType”: “NOT IN”
}]
}

More information can be found about the RESTful API version of Catalina’s Quick Query API can be found here: https://catalinatechnology.wordpress.com/2017/03/02/dynamics-sl-quick-query-through-catalinas-restful-api/

If you want to see more information about Quick Query (particularly about how you can do it in SOAP), you can view that information here: https://catalinatechnology.wordpress.com/2017/02/06/example-of-building-a-form-client-to-use-the-catalina-quick-query-soap-web-service/

Advertisements

Cloud Based Printing and Postage for your ERP or CRM for Sending Invoices, Checks, and more!

Many of us still have customers, vendors, employees, etc. who require printed invoices, checks, letters, or other documents to be mailed to them.  This is a hassle to do.  Extracting and formatting the data, mail-merging, printing, folding, stuffing envelopes, postage, and mailing takes time and costs money.

Catalina Technologies’ Cloud based printing and mailing solution automates this process and merges data from your ERP, CRM, helpdesk, or other system and prints and mails these documents for you.

printmaildiagram

How does this work?  We merge your data into a customizable template, print it, and mail it.  All on the Cloud!  It is just that simple!

(NOTE:  You can jump to the end of this post to see a demo of this in action!)

Data Integration

To make life easier, you want your ERP, helpdesk, CRM, or other system to automatically feed the cloud printing and postage so that you don’t have to do manual steps to get your data out of your back office, merged, printed, and mailed.  Catalina Technology has a full set of integration tools that allows you to integrate from most ERP’s, CRM systems, Helpdesk, or SQL Query, Excel spreadsheet, CSV, etc.  Catalina also has a front-end to Quick Query that allows you to define Quick Query filter definitions that can have custom mapping rules.  These Quick Query filter definitions can then be saved and scheduled as automated jobs.

QuickQuery Output

  • Dynamics SL, GP, and CRM
  • Salesforce.com
  • Any SQL Query
  • Excel spreadsheets
  • .CSV files
  • You can call our API from your system
  • Custom integration

Templating

Templating is an important part of a printing solution.  This allows you to be able to customize how data is merged into the output document to any format you want.

invoice template

These can then be printed as:

  • Invoices
  • Letters
  • Postcards
  • Holiday cards
  • Checks
  • Anything you would normally send to a customer, vendor, employee, business associate, etc!

Demo

Here is a quick demo we did on one of our recent webinars showing how we can receive data from Dynamics SL, merge it into invoices, and then send it out to be printed and mailed to your customers.

For more information contact Catalina Technology:  sales@catalinatechnology.com

Example of building a Form Client to use the Catalina Quick Query SOAP Web Service

Example of building a Form Client to use the Catalina Quick Query SOAP Web Service

This is an example of how to use Quick Query as a data delivery tool for external systems using Catalina’s API for Dynamics SL.  This example is for those who want to use a SOAP based interface.

For an example on how to retrieve Quick Query data through a REST interface, check out this article: Dynamics SL Quick Query through Catalina’s RESTful API

1.     In Visual Studio, we select the Visual C# Template for a Windows Form Application. Our client will be named: client.ctDynamicsSL.quickQuery.

ss1

Note: you can call the Catalina web services from any type of client that is able to make http/https calls, but for this example, we will use a Form Application.

2.     Add a reference to our Quick Query Web Service
a.     Right click on “References” and select “Add Service Reference” 

ss2

b.     On the “Add Service Reference” screen, click the “Advanced” button in the bottom left. (Image: qqcclient3.png)

c.      On the “Service Reference Settings” screen, click the “Add Web Reference” button. (Image: qqcclient4.png)

d.     On the “Add Web Reference” screen, enter in the URL to the web service. 

E.g.: http://localhost/ctDynamicsSL/quickQuery.asmx

Click the arrow button to discover the web service schema.

After the service definition loads, enter in a name to refer to this service in your client.

E.g.: ctDynamicsSL.quickQuery

ss3

e.     Click the “Add Reference” button.

f.       The new web reference will show up in your project.

ss4

 

3.     Create code to instantiate an object referencing our web service.

a.     I like to store values that are required in the Soap Header in the app.config file using System.Configuration, so we will first add a reference to the System.Configuration assembly. References -> Add Reference -> System.Configuration

ss5

b.     Create a private variable to store the actual object and a property to auto create the instance if the variable is null. This get{} property will pull the required header values from the app.config

ss6

Now whenever we want to call a function in the web service, we just reference it like so: myQQObj.functionName().

4.     Add the necessary elements for our main Form.

a.     TextBox for typing in a QueryViewName (tbQueryViewName)

b.     Button for a QueryViewName search (btnSearch)

c.      Button for executing our search (btnGetQuery)

d.     DataGridView for holding our search parameters (dgvFilters)

e.     ss7DataGridView for holding our search results (dgvQueryResults)

 

5.     Add a popup form for QueryViewName searches.

a.     The QueryViewName is the root of the Quick Query Service; they are names of SQL Views built in to SL. This is a required element, so let’s build an easy way to lookup them up.

b.     Add another Form object to the project: queryViewsPopup.cs

ss8.png

c.      Add a DataGridView to the new Form object.

d.     Click on the little arrow at the top right of the Grid and add ctDynamicsSL.quickQuery.vs_qvcatalog as the Data Source.

ss9.png

e.     For ease of use, edit the DataGridView Columns.

  • Move the QueryViewName column to the first position.
  • Change Name to “QueryViewName” we will use this to reference the cell later.

ss10

f.       On our main Form, tie an EventHandler to open this form.

g.      Add a CellDoubleClick Event Handler, to take the selected row and return the QueryViewName back to the tbQueryViewName on the main Form.

ss11.png

6.     Setup Filters DataGridView 

a.     The Quick Query Service getScreen call requires 2 parameters: queryViewName, filters[]. The filters parameter is of type: ctDynamicsSL.quickQuery.queryFilter.  

b.     The Filters is an array of triplets holding 3 required fields:

  • name – This must match the name of a column in the query view)
  • value – This is the value we are to filter/compare against)
  • comparisonType – This is any valid SQL comparison operator. E.g.: =, <, >, LIKE, IN, NOT IN

c.      Select the Data Source as ctDynamicsSL.quickQuery.queryFilter

ss12

7.     The Quick Query Service, is a V2 service by Catalina Technology and by design uses a screen() object for most calls that replicate the SL screen. Create a private variable to hold an instance of the screen object for all of our subsequent calls to the service.

ss13

8.     Write the code to call the web service, pass the parameters and tie the results to the Result DataGridView (dgvQueryResults)

ss14.png

9.     Test our Web Service Client:

a.     Find a Query View with our popup.

ss15

b.     Enter in some filters then Search and View the Results

ss16.png

 Note:     You can download the sample client Visual Studio Project at the following link: https://github.com/CatalinaTechnology/ctAPIClientExamples/tree/master/client.quickQuery