The CreatorCon Call for Content is officially open! Get started here.

Check for unique match possible via indexOf()?

Zod
Giga Guru

Hi,

I'm using a indexOf Function, but need to know if there is exactly only one match?

Something like

if (variable.indexOf(key) == 1) {

was what came into my mind ... but it does not work ;-(

Could you please help out?

Thank you

17 REPLIES 17

This is the part that still confuses me:



i only want the group if there is only one match.



I auto assign group with this only if only one match for relevant group is found



If you are only interested in an exact match of 1, why do you care if anything else is returned - it doesn't sound like you're doing anything with it. What is the value of knowing the user is in two groups of type "X"?


If the user belongs to one incident group - I return the group



if user does not belong to any inc group or to more than one inc group I return nothing.



if an inc group is also from type problem is not relevant


Hi,



Thanks for the clarification. Unfortunately my schedule does not permit me to dig in to this further. I believe the logic of counting records, filtering on types, etc is all there. You may have to re-arrange some pieces, but with some clever testing and debugging, I'm sure you can handle it from here.