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

Zod
Giga Guru

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

6 REPLIES 6

Mihir Mohanta
Kilo Sage

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.


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 ...


Abdul Rizwan
Kilo Contributor

Hi Zod,

The system does not allow you to make a field unique while there are duplicate values in the table.

For reference :

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/field-administrat...

Best Regards,
Abdul Rizwan

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.