Problems with Eval Javascript in Transform Table Pattern Operation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 11:11 AM
I am writing up a horizontal discovery pattern that is bringing back Display (monitor) information. When I am performing the Transform Table operation, I have one field that takes the Manufacture and should return the Manufacture SysID from the core_company table. The code below is not returning a proper SysID when I have it in the field as Eval Javascript:
var newVendor = ${displaysMonitor1[].monitorVendor1};
var mm = Packages.com.snc.cmdb.MakeAndModel.fromNames(newVendor , null);
var mfgSysID = mm.getManufacturerSysID();
ms.log("Debug ::" + newVendor+ "::" + mfgSysID);
rtrn = mfgSysID;
The vendors being returned are in the core_company table. I am getting no errors from the script. mm and mfgSysID are coming back undefined.
What else can I try?
Thanks,
Tom
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 04:28 AM
Okay is this in a Transform or Set operator? Can you try to add a debug line to output the type of newVendor? You should be able to use typeof to do that. I am wondering if what's being returned since it's in a table and there are more then 1 value (although if you are in a transform operation I believe it should only return a string) it may be returning it as an object instead of a string and this is why the call isn't returning what you expect.
I've had this issue before with evals because the ${} returns things as java arraylists and other types that you have to convert sometime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 04:42 AM
This is in a Transform Table operation. Added the debug and here is a result:
09/14/18 07:38:33 (782) Worker-Interactive:PatternDebuggerProbe *** Script: Debug :: typeof newVendor string typeof mm undefined
newVendor is string
mm is Undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 05:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 05:11 AM
OK.
Let me see what I can do/find out. Thanks for the suggestions and looking into this.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 05:52 AM
Yep Pre/Post Processing under pattern designer should do exactly what you want. This way you can just set the value and access it with the Post Processing to actually do the normalization for you. If this works feel free to mark an answer as correct and I wish you the best of luck!