Fetch Data from System Property to Transform MAP

Vamshi_ch123
Tera Contributor

Hi All,

I have a requirement to store the json payload in the system property and use this in transform map field mapping for a specific source field, (source fields having this values source.u_device_class = dvr - snmp)

below is the system Property

system property

Name: DeviceClassMapping 

{
"deviceClass": {
"dvr - snmp":"cmdb_ci_server",
"dvr - windows":"cmdb_ci_win_server",
"servers - windows":"cmdb_ci_win_server",
"servers - linux":"cmdb_ci_linux_server",
"servers - generic":"cmdb_ci_server"

}

}

And Now I'm getting this property to Mapping field in transform map field mapping where I need to map CI class based on deviceclass

Vamshi_ch123_1-1725901670782.png

answer = (function transformEntry(source) {

    var ciClass = "";

    var devClass = gs.getProperty('DeviceClassMapping ');
    var nClass = JSON.parse(devClass);
    var sourceDeviceClass = source.u_device_class.toString().toLowerCase();
     ciClass = nClass.deviceClass[sourceDeviceClass];

   
    return ciClass;

})(source);

the class is not getting updated in the above way unless I hardcode it as below 

 var targetClass = " ";

    var deviceClass = source.u_device_class;

    if (deviceClass == "Dvr - Windows" || deviceClass == "Servers - Windows") {
        targetClass = "cmdb_ci_win_server";
    } else if (deviceClass == "Dvr - Snmp" || deviceClass == "Servers - Generic" || deviceClass == "Servers - Vcenter") {
        targetClass = "cmdb_ci_server";
}
 
Can anyone please help how to do it
 
Thank you
0 REPLIES 0