- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 06:42 AM
Hi ,
We have the excel file contain below data.
Created transform map to update the table based on the excel sheet and u_vm coalesce is true
We need to update the Most Recent Discovery to be updated based on the data on the excel sheet. If there is no update , and excel sheet contain data it should get updated .
How to implement?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:17 AM
Hi
Just saw your recent comment, what I have suggested should work for you. If not you can try with a Transform Script as below:
Write a On After Transform Script and use the script as below:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var sourceVM = source.u_vm.toString();
var gr = new GlideRecord('Give your target Table Name here');
gr.addQuery('name',sourceVM);
gr.query();
if(gr.next()){
target.last_discovered = new GlideDateTime();
target.update();
}else{
ignore=true;
}
})(source, map, log, target);
Screenshot for reference below:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:02 AM
I'm a bit curious on why you would want to update the most recent discovery value, as this is clearly a data import, and typically you want to use that field for Discovery or Service Graph Connectors exclusively.
That being said, if you are determined to update the field, the field name is "last_discovered" (Most Recent Discovery is the label). I would script the result like the following:
var gt = new GlideDateTime();
answer = gt.toString();
(you may not even need to cast it to a string)
Also, you likely also want to provide a Data Source if you are setting the last_discovered date. You also may want to set a scripted "first_discovered" field to be set like the above if it doesn't already exist. That would set a consistent behavior with Discovery & Graph Connectors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:06 AM
As a follow-up, an even better approach would be to leverage the IRE with your transform.
Instructions can be found here:
https://community.servicenow.com/community?id=community_blog&sys_id=7e3fb6d5db5afb00fece0b55ca9619e3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:13 AM
Hi Brian,
Similar like Discovery , i am trying to do in Transform Map.
we have set u_vm as coalese as of now .
Need a Transform Script to check if the data is present in the excel sheet and target table.
If the data is there on the Source table and Target table then we need the most_recent_discovery field to be updated with today's date .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:13 AM
Ideally, This field will be set by the sensor scripts during Identification phase after all the necessary fields which were found are updated in the database.
Can you explain the use case on why you need to update it manually here?
If you still need to go down this path, then you can create a Field Map and select Target Field as "Most recent Discovery" and update it as shown below:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke