Skip to main content
May 24, 2021
Question

How to not inset the duplicates into the database

  • May 24, 2021
  • 11 replies
  • 0 views

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

    11 replies

    davel001150
    May 24, 2021

    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.

    said0002Author
    May 24, 2021

    Hi David,

    Thank you for your quick response......

    still, it is creating so many duplicates...

    a!gridField(
    label: "",
    /* Replace the dummy data with a query, rule, or function that returns a datasubset and uses fv!pagingInfo as the paging configuration. */
    data: todatasubset(local!Taglist, fv!pagingInfo ),
    columns: {
    a!gridColumn(
    label: "",
    sortField: "tagname",
    value: upper(fv!row.tagname),
    width: "AUTO"

    )
    },
    pageSize: 4,
    selectable: true,
    selectionStyle: "ROW_HIGHLIGHT",
    selectionValue: local!selection,
    selectionSaveInto: {
    local!selection,
    a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
    a!save(local!selectedEmployees,difference(local!selectedEmployees, fv!deselectedRows))
    /*a!save(local!selectedEmployees,local!selectedEmployees.GroupId : ri!groupid),*/
    /*updatearray(local!selectedEmployees, 1, local!selectedEmployees.GroupId = ri!groupid)*/
    }
    ),

    Please provide the another solution for this issue..

    thank you