<?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 Creating multiple records Instead of creating one. in CMDB forum</title>
    <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352948#M17059</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After we do service-mapping in CMDB, We will save the view and it will be saved in the Map Views (ngbsm_view)&lt;/P&gt;&lt;P&gt;So, once I save the view, usually I will also save the same for the owned by of the business application.&lt;/P&gt;&lt;P&gt;So, now I have written a BR to avoid doing this manually. But the BR is creating multiple records, that is more than 150. I have seen 186 has come up, when I open a Saved View, changed the version and right click on the form header then Insert and Stay.&lt;/P&gt;&lt;P&gt;So, can some one help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My BR:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lucky1_0-1755253667475.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/463166i08B0E21ABEE89F40/image-dimensions/572x382?v=v2" alt="Lucky1_0-1755253667475.png" title="Lucky1_0-1755253667475.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lucky1_1-1755253698686.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/463167iC2C1C40A6E715A8A/image-dimensions/567x312?v=v2" alt="Lucky1_1-1755253698686.png" title="Lucky1_1-1755253698686.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;</description>
    <pubDate>Fri, 15 Aug 2025 10:28:33 GMT</pubDate>
    <dc:creator>Lucky1</dc:creator>
    <dc:date>2025-08-15T10:28:33Z</dc:date>
    <item>
      <title>Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352948#M17059</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After we do service-mapping in CMDB, We will save the view and it will be saved in the Map Views (ngbsm_view)&lt;/P&gt;&lt;P&gt;So, once I save the view, usually I will also save the same for the owned by of the business application.&lt;/P&gt;&lt;P&gt;So, now I have written a BR to avoid doing this manually. But the BR is creating multiple records, that is more than 150. I have seen 186 has come up, when I open a Saved View, changed the version and right click on the form header then Insert and Stay.&lt;/P&gt;&lt;P&gt;So, can some one help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My BR:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lucky1_0-1755253667475.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/463166i08B0E21ABEE89F40/image-dimensions/572x382?v=v2" alt="Lucky1_0-1755253667475.png" title="Lucky1_0-1755253667475.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lucky1_1-1755253698686.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/463167iC2C1C40A6E715A8A/image-dimensions/567x312?v=v2" alt="Lucky1_1-1755253698686.png" title="Lucky1_1-1755253698686.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 10:28:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352948#M17059</guid>
      <dc:creator>Lucky1</dc:creator>
      <dc:date>2025-08-15T10:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352950#M17060</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/21188"&gt;@Lucky1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You shouldn’t use insert() or update() on current in an after Business Rule when working on the same table. This will try to save the same record again, which can cause duplicates or infinite loops.&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;If you just need to set values on the same record, use a before Business Rule. ServiceNow will save the changes automatically.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 10:57:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352950#M17060</guid>
      <dc:creator>Raghu Ram Y</dc:creator>
      <dc:date>2025-08-15T10:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352953#M17061</link>
      <description>&lt;P&gt;&lt;FONT face="georgia,palatino" size="3" color="#000000"&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/21188"&gt;@Lucky1&lt;/a&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="3" color="#000000"&gt;You are creating a record in &lt;EM&gt;&lt;STRONG&gt;ngbsm_view&lt;/STRONG&gt; &lt;/EM&gt;table 'after' record 'insert' in the same table using BR.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="3" color="#000000"&gt;Check your logic and change the table and when to run conditions, it should work fine.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="3" color="#000000"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino" size="3" color="#000000"&gt;Bhuvan&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 10:51:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352953#M17061</guid>
      <dc:creator>Bhuvan</dc:creator>
      <dc:date>2025-08-15T10:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352978#M17062</link>
      <description>&lt;P&gt;Hi Raghu,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then how can I achieve my logic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 12:03:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352978#M17062</guid>
      <dc:creator>Lucky1</dc:creator>
      <dc:date>2025-08-15T12:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352981#M17063</link>
      <description>&lt;P&gt;Hi Bhuvan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I change the table, because I want to create one more record to the Business owner?&lt;/P&gt;&lt;P&gt;So, can you guide me how to achieve my task then?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 12:05:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352981#M17063</guid>
      <dc:creator>Lucky1</dc:creator>
      <dc:date>2025-08-15T12:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352997#M17064</link>
      <description>&lt;P&gt;Hello Bhuvan and Raghu,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's working because I have changed the decision and now went with Fix scripts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lucky&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 12:24:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3352997#M17064</guid>
      <dc:creator>Lucky1</dc:creator>
      <dc:date>2025-08-15T12:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multiple records Instead of creating one.</title>
      <link>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3353550#M17086</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/21188"&gt;@Lucky1&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for sharing the screenshots. The reason your Business Rule (BR) is creating multiple (150+ records) is because&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You’re running the BR after Insert on the ngbsm_view table. When you do "Insert and Stay", it re-triggers the BR multiple times due to dependencies (sub-records or related inserts happening behind the scenes when a Service Map is saved).&lt;BR /&gt;2. The script does not check for existing records, so each execution inserts a new duplicate record without validation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution Approach might be helpful&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;You need to add a duplicate check and carefully define conditions to avoid multiple inserts. Here’s how&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Modify your BR Script (I am not good in Scripting, Please check carefully)&lt;/P&gt;
&lt;P&gt;(function executeRule(current, previous /*null when async*/) {&lt;BR /&gt;gs.log("Inside BR for CI: " + current.configuration_item);&lt;/P&gt;
&lt;P&gt;// Ensure CI and owner exist&lt;BR /&gt;if (!current.configuration_item || !current.configuration_item.owned_by) {&lt;BR /&gt;gs.log("Skipping BR as CI or owner is missing");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;var gr = new GlideRecord('ngbsm_view');&lt;BR /&gt;gr.addQuery('configuration_item', current.configuration_item);&lt;BR /&gt;gr.addQuery('version', current.version);&lt;BR /&gt;gr.addQuery('user', current.configuration_item.owned_by);&lt;BR /&gt;gr.query();&lt;/P&gt;
&lt;P&gt;if (!gr.next()) {&lt;BR /&gt;// Only insert if a record does not exist&lt;BR /&gt;var newView = new GlideRecord('ngbsm_view');&lt;BR /&gt;newView.initialize();&lt;BR /&gt;newView.configuration_item = current.configuration_item;&lt;BR /&gt;newView.version = current.version;&lt;BR /&gt;newView.user = current.configuration_item.owned_by;&lt;BR /&gt;newView.insert();&lt;/P&gt;
&lt;P&gt;gs.log("New Map View created for Owner: " + current.configuration_item.owned_by);&lt;BR /&gt;} else {&lt;BR /&gt;gs.log("Skipping insert - record already exists for this CI, version, and owner.");&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;})(current, previous);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Change BR Conditions&lt;BR /&gt;* Keep it as After Insert only.&lt;BR /&gt;* DO NOT run it on Update (to prevent recursion when version changes).&lt;BR /&gt;* Add a Filter Condition like:&lt;BR /&gt;* configuration_itemISNOTEMPTY&lt;BR /&gt;* configuration_item.owned_byISNOTEMPTY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Alternative: Use Async BR&lt;BR /&gt;If still multiple inserts are happening because the ngbsm_view insert triggers related actions, convert your BR to Async (delayed execution after the insert is committed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please appreciate the efforts of community contributors by marking appropriate response as&amp;nbsp;Mark my Answer Helpful or Accept Solution&amp;nbsp;this may help other community users to follow correct solution in future.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank You&lt;BR /&gt;AJ - TechTrek with AJ - ITOM Trainer&lt;BR /&gt;LinkedIn:-&amp;nbsp;&lt;A href="https://www.linkedin.com/in/ajay-kumar-66a91385/" target="_blank"&gt;https://www.linkedin.com/in/ajay-kumar-66a91385/&lt;/A&gt;&lt;BR /&gt;YouTube:-&amp;nbsp;&lt;A href="https://www.youtube.com/@learnitomwithaj" target="_blank"&gt;https://www.youtube.com/@learnitomwithaj&lt;/A&gt;&lt;BR /&gt;Topmate:- &lt;A href="https://topmate.io/aj_techtrekwithaj" target="_blank"&gt;https://topmate.io/aj_techtrekwithaj&lt;/A&gt; (Connect for 1-1 Session)&lt;BR /&gt;ServiceNow Community MVP 2025&lt;/P&gt;</description>
      <pubDate>Sun, 17 Aug 2025 06:39:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/cmdb-forum/creating-multiple-records-instead-of-creating-one/m-p/3353550#M17086</guid>
      <dc:creator>AJ_TechTrek</dc:creator>
      <dc:date>2025-08-17T06:39:36Z</dc:date>
    </item>
  </channel>
</rss>

