Ticks in Select

Hi,

I have a collection being pulled from Xano of names and forms where there may be duplicates. I have gotten AI to write me a javascript that will show a list of distinct names and forms for a Select element.

If I have 2 of the same name but in different forms, when I select the first name, the second name populates the Select and when I show the dropdown, ticks appear behind the 2 names.

In this instance I select Aaron Peters (4-2), but the select shows Aaron Peters (3-3)

Any idea why this would be happening?

Thanks

Steve

Hey Steve :waving_hand:

I would suggest 2 approaches:

  • either you stick with Javascript. in that case, I’d suggest you ask AI to explain the JS it created for you or reach out to a developer to review the code AI generated.
  • or you try to build this formula with no-code

Right now, based on the information you provided, with no knowledge of how the data set is structured or what the JS formula looks like, I really don’t know why Aaron Peters is appearing twice.

Hi @Joyce ,

There are instances where students may have the same name but be in different classes which are designated in the brackets so that part is fine.

The real issue that when I select Aaron Peters (3-3), Aaron Peters (4-5) gets selected and both instances show ticks.

Video here

and this is the script for the Select

const items = collections['f1c77774-2b78-4312-987d-3e78b09e743b']?.['data'] || [];
const seen = new Set();
return items.filter(item => {
  const name = item?.['Student_Name'];
  const form = item?.['Form'];
  if (!name) return false;
  const key = `${name}-${form || ''}`;
  if (seen.has(key)) return false;
  seen.add(key);
  return true;
});

Thanks

Steve

Thank you for taking the time to put together the video Steve. Unfortunately, it still doesn’t show how your data is structured and how your select is setup so still difficult to help.

Can you show:

  • the array that the select is bound to
  • what field the “label” of the select option is bound to
  • what field the “value” of the select option is bound to

It’d be interesting to know if the “value” field use the student’s unique database id or if uses the student’s name for example

Hi Joyce,

Not to worry; while I was setting the value to Name (Form), I was only setting the value to Name. I rectified that and it corrected the problem.

Classic case of working when you are running on fumes!

Steve

Aaah beautiful! Glad you found the solution :slight_smile:

I hope you get to take a few restoring naps over the weekend!