Home > Forum > Rules, JS, SQL > Prevent duplicate entries

Prevent duplicate entries
0

MVP

I'm banging my head on the wall... I'm sure there is an easy solution but can't figure it out at the moment. I would like to prevent users entering duplicate values in a field when starting a new workflow and I don't want to use the Instance Number to achieve that.

I have a process ABC with field WFD_AttText1. How do I prevent the user to enter a value that already exists in the field WFD_AttText1 of the process ABC?

Thank you.

MVP

Hi Martin,

I would add a business rule, use this in a form rule and execute it on value change. The form rule would empty the field if the value is not unique. So if the field is mandatory this should also have a visible effect. Not sure whether it's possible but you could add an regular expression to check for null and add an appropriate message. I think the RegEx would be something like this ^$ but I haven't tested it.

In addition I would execute the business rule during path transition. Business rule

select
case
when (
select Count(*) from wfelements
where WFD_DTYPEID= {DTYPE_ID}
and WFD_ID <>{WFD_ID}
and WFD_COMID = {COM_ID}
and {WFCONCOL:1723} = '{1723}'
) > 0 then 0
else 1
end as ValueIsUnique.

I tested this with new (unsaved) and saved workflow instances.

I believe calling business rules has been added in version 2020.


Best regards,
Daniel