2022.2

Table Of Contents
Syntaxrules
IntheDataMapper,allscriptsmustbewritteninJavaScript,followingJavaScriptsyntaxrules.For
example,eachstatementshouldendwith;andthekeywordsthatcanbeused,suchasvartodeclare
avariable,areJavaScriptkeywords.TherearecountlesstutorialsavailableontheInternettofamil-
iarizeyourselfwiththeJavaScriptsyntax.Forasimplescriptallthatyouneedtoknowcanbefoundon
thefollowingwebpages:W3Schoolswebsite-JavaScriptSyntaxandhttps://www.w3schools.-
com/js/js_if_else.asp.AcompleteJavaScriptguideforbeginnerscanbefoundhere:https://developer-
.mozilla.org/en-US/docs/Web/JavaScript.
DataMapperAPI
CertainfeaturesthatcanbeusedinaDataMapperscriptdonotexistinthenativeJavaScriptlibrary.
TheseareadditionalJavaScriptfeatures,designedforuseinConnectonly.Allfeaturesdesignedfor
useintheDataMapperarelistedintheDataMapperAPI(see"DataMapperScriptsAPI"onpage360).
ExternalJavaScriptlibraries
TheExternalJSLibrariesboxontheSettingspaneletsyouaddJavaScriptlibrariestoyourcon-
figurationanddisplaysallthelibrariesthathavebeenimported(see"Settingspane"onpage307).
YoucanuseJavaScriptlibrariestoaddmoreJavaScriptfunctionalitytoyourdatamappingcon-
figuration.AnyfunctionsincludedinaJavaScriptlibrarythatisimportedinadatamappingcon-
figurationwillbeavailableinPreprocessorscriptsaswellasActiontasks,Postfunctionsand
JavaScript-basedextractionsteps.
TakethefollowingJavaScriptfunction,forexample:
function myAddFunction(p1, p2) {
return p1 + p2;
};
IfthisissavedasmyFunction.jsandimported,thenthefollowingwouldworkanywhereinthecon-
figuration:
var result = myAddFunction(25, 12); // returns 37!
Setting boundaries using JavaScript
AssoonasyouselecttheOn Scriptoptionasthetriggerforestablishingrecordboundaries(see
"Recordboundaries"onpage226),youareinstructingtheDataMappertoreadthesourcefilesequen-
tiallyandtotriggeraneventeachandeverytimeithitsadelimiter.(Whatadelimiteris,dependsonthe
sourcedataandthesettingsforthatdata;see"Inputdatasettings(Delimiters)"onpage224).
Inotherwords,thescriptwillbeexecuted-bydefault-asmanytimesastherearedelimitersinthe
inputdata.
Page 364