- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 05:17 AM
Hello all,
I've extended a windows os - servers pattern to pull the InstallDate from a server; I'm not using a custom field but using the ootb install_date field that is avaiable on the form.
I've managed to get part of it working but my install_date field does not populate with the date on the ci.
My WMI Query is set like this:
And for the Parse Variable the settings are set to this:
This is the output:
I believe it's not setting the date on the install_date field on the ci because the ci install_date format is in DD-MM-YYYY HH:MM and not YYYYMMDD like above.
Any idea how I can convert this to DD-MM-YYYY and set it on the install_date field on the ci upon discovery.
I was pointed towards 'Set Parameter Value' step and use EVAL( as shown below:
But not entirely sure what to put in here to pull the variable from the step before and convert the date and then set it as well.
Any suggestions or any idea how I can get this fully working would be much appriciated.
Thank you
Solved! Go to Solution.
- Labels:
-
Discovery
-
Orchestration (ITOM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 12:21 PM
Make your life easier by just running the system info command and parse the value from that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 06:21 AM
Hi @SiD2
You mentioned referring to your example script, where can I find this or did you mean the OOB "Linux\Unix OS - Pre Sensor" pre sensor script.
If not are you able to share the example script.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 06:26 AM
Hi @Owais3
Yes, I meant the OOB script as example "Linux\Unix OS - Pre Sensor".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 08:23 AM
Hi @SiD2
Thanks again.
So I had a look at the script and it's pretty much the same as what I posted, I've updated mine a little as shown below:
/*
* 1. Pre sensor: You can change payload before it will be proccesed by Identification Engine.
* Use IEJsonUtility in order to add relevant information to the payload
* Input parameters in Pre sensor mode: payload, patternId
* 2. Post sensor: You can update/add missing info to the DB based on result (Json) from
* Identification Engine
* Output parameters in Post sensor mode: payload
*
*/
var rtrn = {};
//parsing the json string to a json object
var payloadObj = JSON.parse(payload);
var discoveredServer = cmdb_ci_win_server;
var handleOSInstallDate = function() {
try {
var iddate = discoveredServer.install_date;
if (iddate) {
var intiddate = parseInt(iddate);
var gdt = new GlideDateTime();
gdt.setNumericValue(iddate);
discoveredServer.install_date = gdt.getDisplayValueInternal();
}
} catch (e) {
gs.error(e);
}
};
if (Ci.extendsFromTable(payloadObj.items[0].className, 'cmdb_ci_computer')) {
discoveredServer = payloadObj.items[0].values;
}
if (discoveredServer) {
handleOSInstallDate();
}
rtrn = {
'status': {
'message': 'OS - Windows OS - Pre Sensor script finished successfuly',
'isSuccess': true
},
'patternId': patternId,
'payload': JSON.stringify(payloadObj)
};
When I run discovery, I get the following error.
Are you able to guide me further in retrieving the results.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 10:34 AM
Hi @Owais3
Not sure I could trace such from this example but you need to put some gs.info logs in above script in multiple places to see where we are trying to access on null object and take it further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 12:21 PM
Make your life easier by just running the system info command and parse the value from that.