-
New documentation for Importer_lib, ImporterMappingFunctions_lib and ImporterCustomMappingFunctions_lib
New documentation for Importer_lib, ImporterMappingFunctions_lib and ImporterCustomMappingFunctions_lib
ImporterCustomMappingFunctions_lib
ADITO Akademie
Version 1.0 | 21.02.2020
This document is subject to copyright protection. Therefore all contents may only be used, saved or duplicated for designated purposes such as for ADITO workshops or ADITO projects. It is mandatory to consult ADITO first before changing, publishing or passing on contents to a third party, as well as any other possible purposes.
Version | Changes |
---|---|
1.0 |
Document added |
1. How to build your own ImporterCustomMappingFunctions
First you need to start with the function itself. It normally starts with:
function iYourFunction(pObject)
{
//your code
}
Your name should include a lowercase "i" in the beginning and then camelcase the rest.
pObject is your Object which includes all the properties which you define and can use.
In particular the properties can look like this:
function iYourNewFunction(pObject)
{
var firstName = this.InputRecord[pObject.nameString]
if(firstName == undefined)
this.resolveSymbol(pObject, pObject.nameString);
var sum = this.InputRecord[pObject.sumValue];
.
. //do something with the values
.
}
this.InputRecord gives you an one dimensional array with your values from the defined configuration. pObject.YourParameterName is your value.
this.resolveSymbol is a function that resolves the input. It may contain literals string and numbers in curly brackets ({1}) and variables ({tbl.col}).
The property (for example sumValue) has to have the same name here as well as in the serverprocess! |
//this is in your serverprocess inside your 'Mapping' map
[iYourNewFunction,
{
nameString: "'{0}' + ' ' + '{1}'",
sumValue: 2,
}
]
For this example we needed to update user if they are in a different status.
It is always helpful, if you comment your function with the required fields you have to fill.
//this is in your ImporterCustomerMappingFunctions_lib!
.
.
.
/*
* Values of the mapping line:
* contactID --
*
* @name iUpdateContact
* @param {Object} pObject the mapping line
* @return {Boolean} true
* */
function iUpdateContact(pObject)
{
try
{
var alias = this.Config.AliasTo; //this gets the selected alias
var columns = ["STATUS"];
var types = db.getColumnTypes("CONTACT", columns, alias);
var values = ["CONTACTSTATREVIEW "];
var condition = "CONTACTID = '" + pObject.contactID + "'";
this.updateData("CONTACT", columns, types, values, condition, alias);
}
catch(ex) //If it fails it will not update but continue the rest
{
logging.log(ex); //the error will be logged
return false; //and it will return false.
}
return true;
}
.
.
.