Tech Tuesday: Using GETMAPXML/VAR to pass in parameters to a map and getting the data back

While we position SmartConnect as a tool where you don’t need to be a developer to create integrations, we have quite a few developers that want to take advantage of our interface but have all of the power to call a map whenever needed. In the example below we will explore using the GETMAPXML funtion with the VAR tag to provide maximum flexibility in getting back just the records you want.

The GETMAPXML function is defined in the manual at the link below:

GETMAPXML documentation

This allows us to run a map and then get the output of the integration (if it was set to file, XML). There is also an option to pass in variables so you can control your datasource. What this means is you now have the ability to take a SQL Server datasource (as an example) and pass in a criteria like below:

  select * from Customer where CustomerID = ‘GBL_CUSTOMER’

The GBL_CUSTOMER can be set globally, on the map as a default or through pre-tasks or through the web service. The code sample below shows how you can pass in this value in either XML or JSON to get the results back.

var url = “http://webServiceAddress:5557/smartconnect.svc”;
var password = “xxxxxxxxx”;
var username = “user”;
var domain = “domain”;
var RunMapId = “MAP”;
var method = “getmapxml/var”;
var accept = “”;

//JSON Section
var varString = @”[{“”Key””:””GBL_CUSTOMER””,””Value””:””C””},{“”Key””:””GBL_VAR2″”,””Value””:””XXXXXXXXX””}]”;
accept = “application/json”;
//XML Section
//var varString = @”<ArrayOfVariableOfstringstring xmlns=””http://schemas.datacontract.org/2004/07/eOne.SmartConnect.Engine””><VariableOfstringstring><Key>GBL_CUSTOMER</Key><Value>c</Value></VariableOfstringstring><VariableOfstringstring><Key>GBL_THIS</Key><Value>THAT</Value></VariableOfstringstring></ArrayOfVariableOfstringstring>”;
//accept = “text/xml”;

var urlCalled = string.Format(“{0}/{1}/{2}”, url, method, RunMapId);

var sendString = varString;
var req = (HttpWebRequest)WebRequest.Create(urlCalled);
req.Credentials = new NetworkCredential(username, password, domain);
req.Method = “POST”;
req.Accept = accept;

var reqStream = req.GetRequestStream();
reqStream.Write(Encoding.ASCII.GetBytes(sendString), 0, sendString.Length);

var res = req.GetResponse();
var rdr = new StreamReader(res.GetResponseStream());
var response = rdr.ReadToEnd();

//Do Something with the Data
catch (Exception ex)

As you can see this will give you an incredible amount of flexibility to pull back the data you need for applications like eCommerce sites, Portals, etc. 


1 Comment

  1. James on April 26, 2019 at 12:54 pm

    Hey. Does this work in SmartConnect 2017 as well? Which version does this refer to? I’m trying to make it work with, but the system continually gives me a 500 internal error.


Leave a Comment


Tech Tuesday: Making sure GP is active for SmartPost
Throwback Thursday: Troubleshooting Scheduled Maps
Employee Spotlight: Sandy Westman, Senior Consultant
eOne Offices Closed for Labor Day - Monday, September 7th
eOne Presenting at DynamicsCon 2020 - Free Virtual Conference


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder



open all | close all


Business Central CRM 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 SmartView SOP SQL Support Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.