diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 8adc42b16..e91e6e37e 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -260,7 +260,7 @@ function sendQueryValueNgsi2(entityName, attributes, typeInformation, token, cal * @param {Object} typeInformation Configuration information for the device. * @param {String} token User token to identify against the PEP Proxies (optional). */ -function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token, callback) { +function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, token, callback) { //aux function used to builf JEXL context. //it returns a flat object from an Attr array function reduceAttrToPlainObject(attrs, initObj = {}) { @@ -273,11 +273,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token return initObj; } } - + //Make a clone and overwrite + let typeInformation = JSON.parse(JSON.stringify(originTypeInformation)); let idTypeSSSList = pluginUtils.getIdTypeServSubServiceFromDevice(typeInformation); - //Make a clone and overwrite - typeInformation = JSON.parse(JSON.stringify(typeInformation)); //Check mandatory information: type if (!typeInformation || !typeInformation.type) { callback(new errors.TypeNotFound(null, entityName, typeInformation)); @@ -303,6 +302,8 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token let jexlctxt = {}; //will store the whole context (not just for JEXL) let plainMeasures = null; //will contain measures POJO + //Make a clone and overwrite + typeInformation = JSON.parse(JSON.stringify(originTypeInformation)); //Rename all measures with matches with id and type to measure_id and measure_type for (let measure of measures) { @@ -545,6 +546,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token //PRE-PROCESSING FINISHED //Explicit ATTRS and SKIPVALUES will be managed while we build NGSI payload //Get ready to build and send NGSI payload (entities-->payload) + for (let ename in entities) { for (let etype in entities[ename]) { let e = {};