Creating models on data import

Yadin
Tera Contributor

Working with data import for computer assets.  In the Transform map, I have an onBefore script to handle making the Model for the Computer if one does not already exist.  Not all the script included here, as not relevant to parsing make/model/number out of the input data, and all that is tested working fine.  The issue is, SN isn't actually making the Model entry, but it's not erroring to explain why.  Running as a test in Background Scripts, it pretends everything worked as I see this output:

*** Script: Scheduling: Generate Assets: MacPro (MacPro4,1) for: 2022-11-22 19:53:26

my gs.info tells me: should be Apple Inc. MacPro (MacPro4,1)

So one issue is the display_name is not getting made properly.  The other issue is, it's not making the entry in the model table at all.  I'm not sure why it says "generate assets" though either.  Here is the portion of the script that should be making the entry:

var grNew = new GlideRecord("cmdb_model");

grNew.initialize();

grNew.name = model;

grNew.sys_created_by = "AllSight";

grNew.manufacturer = manu;

grNew.cmdb_model_category = "Computer";

grNew.insert();

gs.info("should be "+manu+" "+model);

Seems pretty straight forward, and I've used similar method to create User records with no issue.  So why won't it actually make the model record?

I'm trying to do it this way so the model is made "properly" because if you just let import create models from what is put in the model field, they lack manufacturer and then proper display name (calculated manufacturer and model name together).  That in turn creates other asset management issues as the asset record isn't made properly for the computer record.  Wish this wasn't so darned complicated...

So, any thoughts or advice why this isn't working and how to make it create these records would be greatly appreciated. 

10 REPLIES 10

Because this is redundant:

Screen Shot 2022-11-30 at 3.50.17 PM.png

I already know the manufacturer, I don't need to see it again in the Model.