<?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: Unique Key violation detected by database - Transform Map in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347654#M919750</link>
    <description>&lt;P&gt;what value you are getting in usr.name in the info message, Also make sure you have not created field map for the same field because you are setting the value of user via transform script.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 12:12:43 GMT</pubDate>
    <dc:creator>Vipul Sethi</dc:creator>
    <dc:date>2022-10-11T12:12:43Z</dc:date>
    <item>
      <title>Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2346358#M919248</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to do an import via a &lt;STRONG&gt;transform map&lt;/STRONG&gt; that uses a script to properly import data&lt;/P&gt;&lt;P&gt;In this code below, i'm formatting fields of the column User so that it can fit the ServiceNow standards for Reference type fields (firstName lastName).&lt;/P&gt;&lt;P&gt;But unfortunately i always get the error "&lt;STRONG&gt;Unique Key violation detected by database ((conn=659) Duplicate entry 'bfc6fac0972611103f0f7b771153af05' for key 'PRIMARY')&lt;/STRONG&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I do realize&amp;nbsp;that a lot of people already&amp;nbsp;posted about this error, but i just can't find a solution for my case in the forum, thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AymanLhend1_0-1665403171262.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/207624iF134011B4214E708/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AymanLhend1_0-1665403171262.png" alt="AymanLhend1_0-1665403171262.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;N.B : user is a &lt;STRONG&gt;reference&lt;/STRONG&gt; field to the system table sys_user&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 12:03:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2346358#M919248</guid>
      <dc:creator>Ayman Lhend1</dc:creator>
      <dc:date>2022-10-10T12:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2346550#M919324</link>
      <description>&lt;P&gt;I would suggest it's better to&amp;nbsp; search the full name on user table and then pass the sys_id in target.user rather then display value , In the below example i am assuming ur getting first name in nonformattarr[0] and last name in nonformattarr[1], you can also break the query in first name and last name also but in below ex i have used full name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var nonformattname = source.u_user;
var nonformattarr =  nonformattname.split(",");
var usr = new GlideRecord("sys_user");
usr.addQuery("name", nonformattarr[0] +" "+nonformattarr[1] );
usr.query();
if(usr.next())
target.user = usr.sys_id;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 14:24:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2346550#M919324</guid>
      <dc:creator>Vipul Sethi</dc:creator>
      <dc:date>2022-10-10T14:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347440#M919657</link>
      <description>&lt;P&gt;This does not generate any errors, but somehow the user field on the target gets populated with the &lt;STRONG&gt;non formatted&lt;/STRONG&gt; value of the name (the one we got from &lt;STRONG&gt;source.u_user&lt;/STRONG&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 09:24:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347440#M919657</guid>
      <dc:creator>Ayman Lhend1</dc:creator>
      <dc:date>2022-10-11T09:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347453#M919666</link>
      <description>&lt;P&gt;I've tried commenting out the part where you assign a value to target.user, and only get information about the user from the DB, but the error still persists&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AymanLhend1_0-1665480569249.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/207878i2B4714140355917D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AymanLhend1_0-1665480569249.png" alt="AymanLhend1_0-1665480569249.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 09:29:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347453#M919666</guid>
      <dc:creator>Ayman Lhend1</dc:creator>
      <dc:date>2022-10-11T09:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347654#M919750</link>
      <description>&lt;P&gt;what value you are getting in usr.name in the info message, Also make sure you have not created field map for the same field because you are setting the value of user via transform script.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 12:12:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2347654#M919750</guid>
      <dc:creator>Vipul Sethi</dc:creator>
      <dc:date>2022-10-11T12:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2350287#M920653</link>
      <description>&lt;P&gt;Throught &lt;STRONG&gt;usr.name&lt;/STRONG&gt; i'm getting the name of the user in the sys_user table after querying via the second value of nonFormattedNameArray + its first value, the query is working&lt;STRONG&gt; just fine&lt;/STRONG&gt;, and it fetches the right name, which means that everything is fine, but when i try to write to &lt;STRONG&gt;target.user&lt;/STRONG&gt; i get that &lt;STRONG&gt;error&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Concerning the field map, i honestly have never used it, and i didn't even &lt;STRONG&gt;mention&lt;/STRONG&gt; it in my script, so i doubt it's related in any way&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 08:18:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2350287#M920653</guid>
      <dc:creator>Ayman Lhend1</dc:creator>
      <dc:date>2022-10-13T08:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Unique Key violation detected by database - Transform Map</title>
      <link>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2355327#M922456</link>
      <description>&lt;P&gt;So after a lot of debugging and headache, i found where the error is coming from.&lt;/P&gt;&lt;P&gt;When i get the first element of the name via &lt;STRONG&gt;nonformattarr[0]&lt;/STRONG&gt;, somehow JS puts a space just before the beginning of the string, which messes up the whole thing and generates the error.&lt;/P&gt;&lt;P&gt;I just had to remove the space at the beginning of the string with &lt;STRONG&gt;String.trim()&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Thank you so much for the help, really appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 09:20:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/unique-key-violation-detected-by-database-transform-map/m-p/2355327#M922456</guid>
      <dc:creator>Ayman Lhend1</dc:creator>
      <dc:date>2022-10-18T09:20:32Z</dc:date>
    </item>
  </channel>
</rss>

