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
  • 0
    Certified Lead Developer

    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.

  • 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

Reply
  • 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

Children
No Data