function setCustomData(element, key, value, writeToDom) {
		var oDataObject = findCustomData(element, key);

		if (value === null) { // delete this property
			if (!oDataObject) {
				return;
			}
			var dataCount = element.getAggregation("customData").length;
			if (dataCount == 1) {
				element.destroyAggregation("customData", true); // destroy if there is no other data
			} else {
				element.removeAggregation("customData", oDataObject, true);
				oDataObject.destroy();
			}
		} else if (oDataObject) { // change the existing data object
			oDataObject.setValue(value);
			oDataObject.setWriteToDom(writeToDom);
		} else { // add a new data object
			element.addAggregation("customData",
				new CustomData({ key: key, value: value, writeToDom: writeToDom }),
				true);
		}
	}
Contains the data modification logic

@private
@param {sap.ui.core.Element} element The element
@param {string} key The key of the desired custom data
@param {string|any} value The value of the desired custom data
@param {boolean} writeToDom Whether this custom data entry should be written to the DOM during rendering