thomasbueck
Tera Contributor

Hi,

take a look in the Pre Post Processing scripts, there are pre processing scripts like 'Handle Model and Manufacturer for HMC' which you can use as example.
You find it directly in the menu with 'pre post' or sa_pattern_prepost_script

AchimM279672093
Tera Contributor

Thanks for your answer.

 

I'm a little bit confused, because ServiceNow is doing it directly, for example in the Network Switch pattern -> discovery -> Step 3 Insert model to cmdb_ci_ip_switch.

If I'm doing the same in a pattern extension it doesn't work.

 

Screenshot 2026-05-07 143937.png

thomasbueck
Tera Contributor

@AchimM279672093 
I assumed you get the model name, which you can't enter directly in the pattern as you need to look up the value. This would be possible with pre post scripts as MakeAndModelJS function can be used there.
If you have the value available you can add it in the pattern. When there is need to transform it you can use EVAL scripts.
This is the kb article: KB0647736 a good explanation video is: https://youtu.be/wuuG85XtL1s?si=wMhS103STTfa9nMj

GlideFast Service Delivery Director/ITOM Architect Robert Geen dives into an advanced ServiceNow Service Mapping topic: using eval scripts inside discovery patterns. While not for everyday use, eval scripts are a powerful tool when you need to go beyond standard parsing methods to handle complex ...

@thomasbueck 

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?