Unicity constraint on multiple fields

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x] Documentation issue or request

Current behavior

I need to have a unicity check for the combined value of 2 fields. E.g. field1 and field2. The combination should be unique.

To achieve this i’ve added a third field (field3) which is configured to be unique. I use a script to fill field3 on add/change edit.

The script works and properly fills field3. Only the unicity check is wrong. When i add a duplicatie value i can save this item without a problem. The correct (and duplicate) field3 is generated and saved. The second time i save this record i do get the error message that this field should be unique.

The docs state that the check on e.g. unique values is after running the script (see: https://docs.squidex.io/02-documentation/developer-guides/scripting). But this behaviour seems to indicate that this check is done before running this script.

Expected behavior

I would expect this check to run after updating conting using a script.

Minimal reproduction of the problem

  • Create new schema with field1, field2, field3
  • Configure field3 to be unique
  • Add script that updates field3 with the value of field1+field2
  • Add 1 content item with a chosen content for field1, field2. Should store properly
  • Add new content item with same value for field1 and field2. Stores item without error
  • Try to save the second content item. Gives validation error on duplicate items.


App Name:

  • [ ] Self hosted with docker
  • [x] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 6.4.0


  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Any clue what’s happening here? Or other way to solve this problem?

Can you show me your script?

This is the script that i’m using:

if (characterCount(ctx.data.organisationtag.iv) > 0) {
    ctx.data.TagGroupAndOrganization.iv = ctx.data.tag.iv + '-' + ctx.data.group.iv + '-' +ctx.data.organisationtag.iv;
else {
    ctx.data.TagGroupAndOrganization.iv = ctx.data.tag.iv + '-' + ctx.data.group.iv;


the docs are wrong in this aspect. The validators run before the scripts.

I do not remember the reason anymore and it is hard to change. But you can play around with this checkbox to validate everything again before a publish:

We were not able to get this working, even with the validate when publishing feature. So we resorted to fixing this in our sync tool that syncs content between environments.