How set a field unique on a custom table ... ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 12:23 AM
Hi,
I have a custom table extending cmdb_ci.
There is a field (u_....), that I wand to set a unique, but when changing it in the table dictionary, the value will not be saved. No message.
If there are duplicate records, I get the message, that setting unique requires duplicates to be removed first .... (but when removed .. nothing happens).
THnx
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 12:45 AM
You can write a before insert/update business rule in that table that will check any other record present or not with same u_xxx field value.
If present use setAbortAction(true) function and not allow the record to insert/update.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 01:09 AM
yes ... ok.
I can even start my coffee maschine somehow with SN 😉
But ... please tell me, why is the OOB not working. I can not be the right thing to do, to just always find a workaround for things that do not work as it should ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 11:25 PM
Hi Zod,
The system does not allow you to make a field unique while there are duplicate values in the table.
For reference :
Best Regards,
Abdul Rizwan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2022 04:55 AM
I have a brand new custom table extending from cmdb_ci. I have a column that I wish to make unique. I have 0 records in my custom table yet I am not able to set the column as unique.