<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Need Most Recent Discovery to update in Data Source in Common Service Data Model forum</title>
    <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329903#M1376</link>
    <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5f12186adb4304502be0a851ca961990"&gt;@Shohaib&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just saw your recent comment, what I have suggested should work for you. If not you can try with a Transform Script as below:&lt;/P&gt;
&lt;P&gt;Write a On After Transform Script and use the script as below:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(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);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Screenshot for reference below:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8440i4194BDBFAA3DA253/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hope this helps. Please mark the answer as correct/helpful based on impact.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Shloke&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2022 15:17:54 GMT</pubDate>
    <dc:creator>shloke04</dc:creator>
    <dc:date>2022-03-08T15:17:54Z</dc:date>
    <item>
      <title>Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329898#M1371</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;We have the excel file contain below data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8443i8654B7E7862E9E75/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Created transform map to update the table based on the excel sheet and u_vm coalesce is true&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to update the Most Recent Discovery to be updated based on the data on the excel sheet. If there is no update ,&amp;nbsp;and excel sheet contain data it should get updated .&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to implement?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8442i0BC8CF717722513F/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 14:42:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329898#M1371</guid>
      <dc:creator>Saib1</dc:creator>
      <dc:date>2022-03-08T14:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329899#M1372</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;var gt = new GlideDateTime();&lt;BR /&gt;answer = gt.toString();&lt;/P&gt;
&lt;P&gt;(you may not even need to cast it to a string)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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 &amp;amp; Graph Connectors.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:02:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329899#M1372</guid>
      <dc:creator>Brian Hoban</dc:creator>
      <dc:date>2022-03-08T15:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329900#M1373</link>
      <description>&lt;P&gt;As a follow-up, an even better approach would be to leverage the IRE with your transform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions can be found here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=7e3fb6d5db5afb00fece0b55ca9619e3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:06:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329900#M1373</guid>
      <dc:creator>Brian Hoban</dc:creator>
      <dc:date>2022-03-08T15:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329901#M1374</link>
      <description>&lt;P&gt;Hi Brian,&lt;/P&gt;
&lt;P&gt;Similar like Discovery , i am trying to do in Transform Map.&lt;/P&gt;
&lt;P&gt;we have set u_vm as coalese as of now .&lt;/P&gt;
&lt;P&gt;Need a Transform Script to check if the data is present in the excel sheet and target table.&lt;/P&gt;
&lt;P&gt;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 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/s/skins/images/B9CAAB319153FD403AE46876C2AEA9E7/responsive_peak/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:13:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329901#M1374</guid>
      <dc:creator>Saib1</dc:creator>
      <dc:date>2022-03-08T15:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329902#M1375</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;DIV class="cm-comment-text cm-comment-view-mode ng-scope" data-ng-if="!comment.showEditMode"&gt;
&lt;DIV class="cm-comment-body"&gt;
&lt;DIV class="cm-comment-text-info"&gt;
&lt;P&gt;Ideally, This field will be set by the sensor scripts during&amp;nbsp;Identification phase after all the necessary fields which were found are updated in the database.&lt;/P&gt;
&lt;P&gt;Can you explain the use case on why you need to update it manually here?&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;answer = (function transformEntry(source) {

	// Add your code here
	var gr = new GlideDateTime();
	return gr; // return the value to be put into the target field

})(source);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8432i54BDBF90A7959B12/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hope this helps. Please mark the answer as correct/helpful based on impact.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Shloke&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="cm-comment-footer cm-common-light-color f-16px ng-scope" data-ng-if="!comment.showEditMode"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:13:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329902#M1375</guid>
      <dc:creator>shloke04</dc:creator>
      <dc:date>2022-03-08T15:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329903#M1376</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5f12186adb4304502be0a851ca961990"&gt;@Shohaib&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just saw your recent comment, what I have suggested should work for you. If not you can try with a Transform Script as below:&lt;/P&gt;
&lt;P&gt;Write a On After Transform Script and use the script as below:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(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);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Screenshot for reference below:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8440i4194BDBFAA3DA253/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hope this helps. Please mark the answer as correct/helpful based on impact.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Shloke&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:17:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329903#M1376</guid>
      <dc:creator>shloke04</dc:creator>
      <dc:date>2022-03-08T15:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329904#M1377</link>
      <description>&lt;P&gt;let me try the above script .&lt;/P&gt;
&lt;P&gt;Scenario is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/8435i2B52B86C3465541F/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:27:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329904#M1377</guid>
      <dc:creator>Saib1</dc:creator>
      <dc:date>2022-03-08T15:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329905#M1378</link>
      <description>&lt;P&gt;Thanks Shloke .&lt;/P&gt;
&lt;P&gt;The above code worked for me.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 15:52:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329905#M1378</guid>
      <dc:creator>Saib1</dc:creator>
      <dc:date>2022-03-08T15:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need Most Recent Discovery to update in Data Source</title>
      <link>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329906#M1379</link>
      <description>&lt;P&gt;Hi Shloke,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the below code you sent to me. I just applied it. It is working fine. And blank record is getting created after this&amp;nbsp; transform script put in my system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;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;
	}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Mar 2022 13:28:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/common-service-data-model-forum/need-most-recent-discovery-to-update-in-data-source/m-p/329906#M1379</guid>
      <dc:creator>Saib1</dc:creator>
      <dc:date>2022-03-14T13:28:02Z</dc:date>
    </item>
  </channel>
</rss>

