Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you might find the site temporarily inaccessible. Thanks for your patience. Read more.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to filter a list output from queryAndSet to show only unique values?

Mar Demolag
Contributor
December 2, 2024

Hi,

given the following forms:

  • devices:
    • device: Text
    • type: Text
  • hardwares:
    • device: Smart Dropdown from devices
    • location: Text

I want to make a tableview for devices, showing the fields of the form + a field showing a list of all the locations of that specific device on the hardwares form.
Currently I use:

id.queryAndSet(hardwares:@self;device:[entry.id];location)

which works, but since one location can have several occurrences of the device, I get a list containing duplicates.
Is there a way to filter the duplicates out of the output?

 

another thing I tried was making a queryAndRender table showing each location and the count of occurrences of the device in the location, but I meet the same issue there.

1 answer

1 accepted

0 votes
Answer accepted
Mar Demolag
Contributor
December 3, 2024

Currently I used the following solution (not great, but works):

I added two formula fields to the hardwares form:

countperlocation: (for each hardware entry, counts the amount of the same device on the hardware's location - will be a duplicate for every entry on the same location)

[entry.id.queryCount(hardwares:@self;device:[entry.device] AND location:[entry.location])]

numperlocation: (similar for the one above, but only count the devices if they were created before the current entry - which in a ways gives them a "serial number" for their location)

[entry.id.queryCount(hardwares:@self;device:[entry.device] AND location:[entry.location] AND created:<[entry.created])]

and on the queryAndRender field I used the following: (show for each location just the first hardware of the same type in the location, and the countperlocation which as said above is duplicated for each of the hardwares)

id.queryAndRender(hardwares:@self;device:[entry.id] AND numperlocation:0;location|countperlocation;table)

 

Will be happy to hear better solutions!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events