How to not inset the duplicates into the database

Hi All,

code:-

!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Create",
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[fv!index], portfolioname: local!filter.value[fv!index], portfolioid: local!filter.customerid[fv!index], tagid: local!filter.tag.tagid[fv!index]}))),

a!writeToDataStoreEntity(
dataStoreEntity: cons!portfoliomasterorg,
valueToStore: local!items
in the above code i am trying to insert the data into Db. how to not insert the duplicates into DB. Please help me to resolve the issue.
Thank you

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to said0002

    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?

Children
No Data