<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to not inset the duplicates into the database</title><link>https://community.appian.com/discussions/f/general/21041/how-to-not-inset-the-duplicates-into-the-database</link><description>Hi All, 
 code:- 
 !buttonArrayLayout( buttons: { a!buttonWidget( label: &amp;quot;Create&amp;quot;, saveInto:{ a!forEach(items: local!filter,expression:a!save(local!items, append(local!items,{customerid: local!filter.customernumber[fv!index], tag: local!filter.tag.tagname</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/82017?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 15:48:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0bad8736-e7d2-46ea-abfe-56f1b0b86064</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;If your intent is to make sure the &amp;#39;customerId&amp;#39; field is unique, you should *REALLY* consider enforcing this constraint on the front-end instead of trying to bend over backwards and use DB write trickery and/or involve super complex stuff like composite primary keys, stored procedures, etc.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s drill back up on this a bit.&amp;nbsp; Under what circumstances would Customer ID be potentially duplicate?&amp;nbsp; Is this hand-entered by a user or generated by internal logic somehow?&amp;nbsp; If user-entered, &lt;strong&gt;&lt;em&gt;all you need&lt;/em&gt; &lt;/strong&gt;is to add on-form validation.&amp;nbsp; If it&amp;#39;s system-generated, then i guess my question is, why is this case possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/82016?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 15:42:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c2d98f77-467a-4352-917b-2d7c03d687d3</guid><dc:creator>said0002</dc:creator><description>&lt;p&gt;Is there any way that we can writr if condition on customer id and not enter repeating customerids......&lt;/p&gt;
&lt;p&gt;code:-&lt;/p&gt;
&lt;div&gt;!buttonArrayLayout(&lt;br /&gt;buttons: {&lt;br /&gt;a!buttonWidget(&lt;br /&gt;label: &amp;quot;Create&amp;quot;,&lt;br /&gt;saveInto:{&lt;br /&gt;&lt;br /&gt;a!forEach(items: local!filter,expression:a!save(local!items, append(local!items,{customerid: local!filter.customernumber[fv!index], tag: local!filter.tag.tagname[fv!index], portfolioname: local!filter.value[fv!index], portfolioid: local!filter.customerid[fv!index], tagid: local!filter.tag.tagid[fv!index]}))),&lt;br /&gt;&lt;br /&gt;a!writeToDataStoreEntity(&lt;br /&gt;dataStoreEntity: cons!portfoliomasterorg,&lt;br /&gt;valueToStore: local!items&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;i have tried but not able to get. Please provide the suggestion...&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;thank you&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/82006?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 13:56:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8188531f-ac73-4b5a-a33d-fa005473df55</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;In that situation I would deeply consider using a Stored Procedure to handle the database writes, and have IT worry about the Composite Keys and not Appian.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81971?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 06:56:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2308eeef-b142-4d11-8aed-257b7bf5f114</guid><dc:creator>vamsi krishna</dc:creator><description>&lt;p&gt;&lt;span style="font-size:150%;"&gt;Appian doesn&amp;#39;t support composite primary keys I think,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:150%;"&gt;So you can concat those columns in DB as a single column and make it primary.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81970?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 06:42:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:df779a18-406f-4e25-a6c5-b08be230127a</guid><dc:creator>said0002</dc:creator><description>&lt;p&gt;How to set the multiple columns as primary key while creating the CDT...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81968?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 04:45:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8de9bf84-87e2-4144-91eb-529f2d8315cd</guid><dc:creator>said0002</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1621917567817v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;i have populated the unique id values before writing the CDT to the DB. ex;-(customerid:- 57331) if customer id already present in the DB, then no need to write that again into DB. Please provide the solution for above problem...&lt;/p&gt;
&lt;p&gt;thank you...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81954?ContentTypeID=1</link><pubDate>Mon, 24 May 2021 18:27:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:65f36746-af8d-4206-87c1-12296799c1c9</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;I think it would be WONDERFUL feature if Appian allowed a way to configure DB node or function to ONLY write or ONLY update, else throw error and pause the process / pink box.&amp;nbsp; The fact that it&amp;#39;s determined at runtime, even though via very explicit and predictable rules, does lead many a developer to problems like this, and adds a bunch of time for all of us to trick it into only doing what we want.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81946?ContentTypeID=1</link><pubDate>Mon, 24 May 2021 17:11:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ac5fe7f7-2968-4e7f-b5e9-bc2d90556629</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Without fully digesting all of your code, this can occur if you are not populating the unique ID values for existing rows before writing the CDT to the DB, so Appian does not realize this should not be a re-entry (update vs insert).&amp;nbsp; If there is no need to update entries, you would want to query for which values are already in the DB, and remove those from the CDT before persisting your data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81942?ContentTypeID=1</link><pubDate>Mon, 24 May 2021 16:58:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e93e2888-6cee-4e8c-a522-d31367e18fe9</guid><dc:creator>said0002</dc:creator><description>&lt;p&gt;when I am clicking on the first-time create button, it is not creating any duplicates, when i am clicking on the second time it not verifying whether the record is already present or not and not to insert the already existing data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81937?ContentTypeID=1</link><pubDate>Mon, 24 May 2021 15:27:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7a45df41-4652-4bbd-9302-4c03346a5db1</guid><dc:creator>said0002</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Thank you for your quick response......&lt;/p&gt;
&lt;p&gt;still, it is creating so many duplicates...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!gridField(&lt;br /&gt; label: &amp;quot;&amp;quot;,&lt;br /&gt; /* Replace the dummy data with a query, rule, or function that returns a datasubset and uses fv!pagingInfo as the paging configuration. */&lt;br /&gt; data: todatasubset(local!Taglist, fv!pagingInfo ),&lt;br /&gt; columns: {&lt;br /&gt; a!gridColumn(&lt;br /&gt; label: &amp;quot;&amp;quot;,&lt;br /&gt; sortField: &amp;quot;tagname&amp;quot;,&lt;br /&gt; value: upper(fv!row.tagname),&lt;br /&gt; width: &amp;quot;AUTO&amp;quot;&lt;br /&gt; &lt;br /&gt; )&lt;br /&gt; },&lt;br /&gt; pageSize: 4,&lt;br /&gt; selectable: true,&lt;br /&gt; selectionStyle: &amp;quot;ROW_HIGHLIGHT&amp;quot;,&lt;br /&gt; selectionValue: local!selection,&lt;br /&gt; selectionSaveInto: {&lt;br /&gt; local!selection,&lt;br /&gt; a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),&lt;br /&gt; a!save(local!selectedEmployees,difference(local!selectedEmployees, fv!deselectedRows))&lt;br /&gt; /*a!save(local!selectedEmployees,local!selectedEmployees.GroupId : ri!groupid),*/&lt;br /&gt; /*updatearray(local!selectedEmployees, 1, local!selectedEmployees.GroupId = ri!groupid)*/&lt;br /&gt; }&lt;br /&gt; ),&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please provide the another solution for this issue..&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to not inset the duplicates into the database</title><link>https://community.appian.com/thread/81931?ContentTypeID=1</link><pubDate>Mon, 24 May 2021 15:06:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dd3e40e6-d439-4201-817c-d95596e8ed1d</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;valueToStore: union(local!items, local!items)&lt;/p&gt;
&lt;p&gt;That&amp;#39;s the absolute fastest way it could possibly be done.&amp;nbsp; Let me know if that doesn&amp;#39;t work, we&amp;#39;ll have to go through a more thorough way of removing duplicates.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>