Discussion posts and replies are publicly visible
valueToStore: union(local!items, local!items)
That's the absolute fastest way it could possibly be done. Let me know if that doesn't work, we'll have to go through a more thorough way of removing duplicates.
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.
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). 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.
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. The fact that it'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.
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...
How to set the multiple columns as primary key while creating the CDT...
Appian doesn't support composite primary keys I think,
So you can concat those columns in DB as a single column and make it primary.
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.
Is there any way that we can writr if condition on customer id and not enter repeating customerids......
If your intent is to make sure the 'customerId' 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.
Let's drill back up on this a bit. Under what circumstances would Customer ID be potentially duplicate? Is this hand-entered by a user or generated by internal logic somehow? If user-entered, all you need is to add on-form validation. If it's system-generated, then i guess my question is, why is this case possible?
© 2022 Appian. All rights reserved.