answer = (function transformEntry(source) { // Handle Model column with or without manufacturer, as long as the model name is unique in the [cmdb_model] table if (source.u_model.toString() !== '') { // Perfect: Model field contains the Model's display name var encQ = 'display_name=' + source.u_model.toString().trim(); // Almost perfect: Concatenate the import table's manufacturer field if supplied to recreate the Model display name if (source.u_manufacturer.toString() !== '') encQ += '^ORdisplay_name=' + source.u_manufacturer.toString().trim() + ' ' + source.u_model.toString().trim(); // Try to find a unique name on the Model table without a manufacturer encQ += '^ORname=' + source.u_model.toString().trim(); var grModel = new GlideRecord('cmdb_model'); grModel.addEncodedQuery(encQ); grModel.query(); // Unique models only if (grModel.getRowCount() == 1) { grModel.next(); return grModel.getDisplayValue(); } else { gs.info("EAM Tactical Asset Transform Map: Unable to create Asset. Found more than 1 Model by the name of: " + source.u_model.toString()); } } })(source);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter