- 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
02-16-2023 06:46 AM - edited 02-16-2023 06:47 AM
here is the basic JS for parsing. Since i don't see delimiter so need to hard code the positions
var installd ='20190410';
var year1=installd.substring(0,4);
console.log(year1);
var mm1=installd.substring(4,6);
console.log(mm1);
var dd1=installd.substring(6,8);
console.log(dd1);
Regards
RP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 08:54 AM
Hi @Owais3
You can't do that date setting in EVAL but you should do it in a pre sensor script.
Refer this SNOW API doc for GlideDateTime object and the available methods. You can use some setDisplayValue variants and again get the value using getDisplayValueInternal() api and then set it to install_date field in the pre sensor.
You can refer OOB "Linux\Unix OS - Pre Sensor" pre sensor script for setting the field value with getDisplayValueInternal().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 06:38 AM
Hi @SiD2
Thanks for guidance. Below is a Pre Sensor Script.
How do I refer to the variable set in my pattern and point it to the field. the getDisplayValueInternal() is being used but i'm not seeing the results.
The install_date was populated but with an incorrect date:
01-01-1970 07:36
var rtrn = {};
//parsing the json string to a json object
var payloadObj = JSON.parse(payload);
var discoveredServer = null;
var handleOsStartTime = function()
{
try{
var stdate = discoveredServer.install_date;
if(stdate){
var intStdate = parseInt(stdate);
var gdt = new GlideDateTime();
gdt.setNumericValue(stdate);
discoveredServer.install_date = gdt.getDisplayValueInternal();
}
}
catch (e) {
gs.error(e);
}
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 06:03 AM
Hi @Owais3
You need to access the date value from the payload after parsing "JSON.parse(payload);" but I don't see it in above script.
You can refer my example script where it retrieves the JSON of the server in the payload and then access it's date field.
Once you have the date field value from the payload above then apply the GlideDateTime API ref which I shared and then use getDisplayValueInternal and assign it back to actual field install_date inside the payload.