EONE BLOG

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.


try
{
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);
reqStream.Close();

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

//Do Something with the Data
MessageBox.Show(response);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

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. 

Thanks,
Chris

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 20.17.0.17, but the system continually gives me a 500 internal error.

    Thanks!

Leave a Comment




RECENT POSTS


US Memorial Day eOne Office Hours - May 27th, 2019
SmartConnect Bootcamp in St. Louis - Don't Miss It!
Directions North America 2019: We Loved It!
Tech Tuesday: Creating a Popdock endpoint to use with Power BI
SmartConnect Office Hours Recap for May 17th, 2019

POPULAR POSTS


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

CATEGORIES

ARCHIVES

open all | close all

TAGS

CRM Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News eOne Spotlight ERP Events Excel Excel Report Builder Extender Extender Enterprise Flexicoder GP GPUG integration integration manager Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners Popdock release Reporting 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.