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

Leave a Comment




RECENT POSTS


Now is the time for SmartList Builder. Convince Your Boss to Dive In!
Tech Tuesday: GP SOP Update Integrations
Reminder: Don't Forget to Register for the SmartConnect Orlando Bootcamp!
Tech Tuesday: Getting Extender Data to Appear in SmartList
Join us in Orlando for the first 2019 SmartConnect Bootcamp!

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 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 Extender Enterprise Flexicoder GP GPUG integration integration manager Meet the Team Microsoft Microsoft dynamics crm Microsoft Dynamics GP MSDYNGP Office Relationships partners release SalesForce SalesForce.com scripting SmartConnect 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.