Validate a repeat to not have duplicates options selected

246
1
Jump to solution
01-21-2019 01:07 PM
Highlighted
New Contributor II

I need to validate a repeat to not have duplicates options selected. 

I think the workaround for this is to use a calculate using join('',${selectOnevariable}) and then another calculate to check if string have duplicates, I think using a regex could be done. The thing is that I'm not able to find a good expression to validate this. Obviously you can have consecutive duplicates (ej. 001 001) or non consecutives (ej 001 002 001)

Any ideas?

Regards,

Daniel R.

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

I was able to apply a constrain to the select-on field using a constrain with the following steps:

1.- Calculate a join of the field: ej join('',${fieldselectone})

2.- Calculate isrepeated field inside the repeat using a regular expression: regex(join('',${fieldselectone}),concat('^[0-9]*(',${fieldselectone},')[0-9]*(',${fieldselectone},')[0-9]*$'))

Just note I'm using numbers [0-9] as the character set because on my case the ${fieldselectone} is a numeric code list, you could replace this wit [A-Z] or [A-Z0-9] for alpha

3.- Apply the isRepeated field as constrain on the ${fieldselectone}. Ej not(boolean-from-string(${isRepeated}))

 

I hope it works for you.

Regards,

Daniel R.

View solution in original post

1 Reply
Highlighted
New Contributor II

I was able to apply a constrain to the select-on field using a constrain with the following steps:

1.- Calculate a join of the field: ej join('',${fieldselectone})

2.- Calculate isrepeated field inside the repeat using a regular expression: regex(join('',${fieldselectone}),concat('^[0-9]*(',${fieldselectone},')[0-9]*(',${fieldselectone},')[0-9]*$'))

Just note I'm using numbers [0-9] as the character set because on my case the ${fieldselectone} is a numeric code list, you could replace this wit [A-Z] or [A-Z0-9] for alpha

3.- Apply the isRepeated field as constrain on the ${fieldselectone}. Ej not(boolean-from-string(${isRepeated}))

 

I hope it works for you.

Regards,

Daniel R.

View solution in original post