Pattern Designer model_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello,
I would like to set the model for an SNMP device in Pattern Designer.
I can read the model via sysdescr, but I can’t enter this value directly under $cmdb_ci_ip_switch[*].model_id. To do that, I would need to know the model_id.
This is, of course, difficult because the model may not have existed previously, and even if it did, I can’t find a way to determine the model_id in Pattern Designer.
Unfortunately, the Pattern Designer does not have the MakeAndModelJS function, as is available for probes/sensors.
Does anyone know of a way to enter the model in plain text?
I would appreciate a response.
Best regards,
Achim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I was able to extract the model using the pattern from the SNMP sysdescr. However, I can't write this value to the model_id field because it expects a sys_id there. In the video you mentioned, this is done without a sys_id, but it doesn't show whether it actually works. I doubt it does. I’d like to stick with the pattern, since that’s probably the way of the future, but there’s no way to call MakeAndModelJS (I get errors in EVAL) or an alternative method that replaces MakeAndModelJS.
I’m aware of the pre/post scripts, but I haven’t implemented them yet. I also don’t know how to use the variables/values determined in the pattern in the post script afterward.
Has anyone done this before?
Used MakeAndModelJS in pre/or post scripts with parameter passing from the pattern?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
@AchimM279672093 Pre and post scripting is standard it's ootb and it will always be used as EVAL has it's limitations.
If you copy and modify the logic of an existing script it's pretty easy. There are several scripts which are using MakeAndModelJS - you can search for it and use the logic.
In the script you have the payload, f.e. this pattern: "Handle Model and Manufacturer for EMC Isilon"
This is the script:
You only need to add your pattern under "Patterns" that ServiceNow knows when your script needs to run.
Give it a try - I was surprised how smooth it worked.
Kind Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Yes, thats what I saw already. All scripts, which are using MakeAndModelJS are Pre scripts. Maybe I'm wrong, but I need it in a Post script, because I calculate/read the actual model only in the pattern, i.e. after the Pre phase. Otherwise, I’d have to read the model from sysdescr via JavaScript to set it in the Pre script. That would probably work too, but the Pattern Designer is more convenient for this. Gerne würde ich das Post Script benutzen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
@AchimM279672093 Was the same for me, but Pattern Designer has it's limitations and a pre script worked fine.
From my experience, pre-script runs after the pattern designer, but for the save.
I could use the data, which I fetched in a custom step.
Don't forget: Probieren geht über studieren 😉