Skip to main content
October 10, 2023
Question

How to remove duplicate index form local(Array)

  • October 10, 2023
  • 4 replies
  • 0 views

Hi  i have a requirement to show only unique index value while using for each

how can i do that ?

in local!voucher Details have 4 item that is duplicate i need only unique value

    4 replies

    shikhat
    October 10, 2023

    Hi ,

    You can use union function to get distinct values .
    union(local!voucherDetails,local!voucherDetails)

    rishikeshr4182
    October 10, 2023

    I have tried to replicate your use, plz refer this.


    a!localVariables(
      local!test: {
        {
          username: "",
          buduget: 2023,
          dept: 123456789
        },
        {
          username: "",
          buduget: 2023,
          dept: 123456789
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        }
      },
      union(local!test, local!test)
    )

    natarajanm0529
    October 26, 2023

    How to keep only unique based on the dept value? 

    rishikeshr4182
    October 27, 2023

    you can use the union function, it compares all the fields.