SmartConnect - Using a Global Variable

This article applies to SmartConnect, the system that it attaches to is not really important (but I happen to be doing an integration from a SQL table into Dynamics 365 Business Central

The task today was to aggregate errors in the integration and report them via email at the end. So... we'll need a global variable

 

 

 

Got to this window

Add a global variable 

In our example, we'll be viewing the MAPBEGIN, GRRR, AND MAPFAIL scripts, shown below. MAPBEGIN will initialize, GRRR will aggregate the errors, and MAPFAIL will send the email

Initiailize

Aggregate. I'm using the GlobalLastError variable, which has some issues. Notably, it needs to be initialized or it won't have data, and it contains single quotes which sends my SQL sideways. 

Also, SmartConnect does not support a vbCRLF character, so (out of view in this screen shot) I'm adding #crlf# to the end of each error

At any rate, I'm collecting errors.

Replace #crlf# with char(13) + char(10)

Send an email. 

 

 

 

 



RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences