Skip to content
+1-888-319-3663

HELP ARTICLE

How to pass a variable into a SmartConnect source query


This article explains how to pass a variable into a source query.

1. When you first create the map, you need to hard code the field that will be the variable. The source query will not validate with a variable in the source query.
For example: SELECT * FROM RM00101

2. Create your map, and map the fields as you normally would.

3. Your code to set the variable should be in a pre map task. A very simple example of this would be: GlobalMessage = “RM00101”

4. After the map is created and running correctly, replace your hard coded value with your variable.
For example: SELECT * FROM GlobalMessage

5. Then run the map. The map will run (but not validate or be able to adjust mappings since global variables do not have values until runtime). If you need to edit the mappings you need to hard code your source query again before you can adjust the mappings in the mapping windows.

If the global variable is being used in the WHERE clause statement and contains a string value then the quotes would need to be put around the value that is assigned in the pre-map task.

1. Build a map with your query to get the column names:
SELECT * FROM RM00101 WHERE CUSTNMBR = ‘AARONFIT0001’

2. Create your map, and map the fields as you normally would.

3. Your code to set the variable should be in a pre map task. A very simple example of this would be: GlobalMessage = “‘AARONFIT0001′”

4. Place the global variable in the source query
SELECT * FROM RM00101 WHERE CUSTNMBR = GlobalMessage

NOTE: Notice that in the last example there are single quotes inside the double quotes. This is because SQL requires strings to be surrounded by single quotes.

RECENT POSTS


Use the REST Connector to parse nested Value Arrays
SmartConnect email task fails with error: An invalid character was found in the email header
Does SmartConnect import into Avalara Avatax software
Could not initialize a collection when launching SmartConnect
ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key when you open a SmartConnect map.

POPULAR POSTS


SSL Security error using OLEDB Connection
This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms
Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))
The server process could not be started because the configured identity is incorrect.
Using WINSCP and a task to upload or download files from an SFTP site

CATEGORIES

TAGS

Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships partners Popdock release Reporting SalesForce SalesForce.com SmartConnect SmartConnect.com SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.