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. 


Leave a Comment


SmartConnect Journal Entry Pack for Business Central
Join us in Las Vegas for our SmartConnect GP bootcamp or BC & NAV bootcamp
Join us in Boston for our SmartConnect Bootcamp - April 24th & 25th
Tech Tuesday: Bringing in expenses from an outside system to NAV/D365 Business Central
SmartConnect Office Hours Recap for March 15th, 2019


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



open all | close all


CRM Demo Dynamics Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News eOne Spotlight ERP Events Excel Excel Report Builder Extender Flexicoder GP GPUG integration integration manager Meet the Team Microsoft Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners release SalesForce SalesForce.com scripting SmartConnect SmartConnect.com SmartConnect Office Hours SmartList SmartList Builder SmartList Designer SmartView SQL Support Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.