- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 04:12 AM
Hi Guys,
I have a table for Web Accounts. The entries should be unique based on the URL and Account ID entered. How to set a combination of 2 fields to be unique.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 06:10 AM
Hi,
You cannot have the table level configurations to create Unique field as combination of two fields. However, you can have a Before insert/update business rule on your table to validate your new entry.
In the script section you can glide to current table and check if the record already exits with current records value i.e URL and Account ID. If record exist abort the operation.
The sample code would be like:
var web_acc = new GlideRecord("web_account_table");
web_acc.addQuery('u_url',current.u_url);
web_acc.addQuery('u_account_id',current.u_account_id);
web_acc.query();
if(web_acc.next())
{
current.setAbortAction(true);
}
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 06:10 AM
Hi,
You cannot have the table level configurations to create Unique field as combination of two fields. However, you can have a Before insert/update business rule on your table to validate your new entry.
In the script section you can glide to current table and check if the record already exits with current records value i.e URL and Account ID. If record exist abort the operation.
The sample code would be like:
var web_acc = new GlideRecord("web_account_table");
web_acc.addQuery('u_url',current.u_url);
web_acc.addQuery('u_account_id',current.u_account_id);
web_acc.query();
if(web_acc.next())
{
current.setAbortAction(true);
}
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 07:35 AM
Thanks Anil!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2025 07:55 AM
This may be an ancient post but the above answer is not true, or is no longer true. You can create a unique index based on multiple fields. If the current data violates the index you want to create you will have to either delete the offending record or delete all records. So this is best done when creating the table.
- Go to table list or form
- Right click header and choose Configure > Table
- scroll down to Database Indexes related list
- If there is an existing index on one of the fields you want to use you can optionally click it and drop the index. However when you create the new index the system will amend that index.
- Click New
- Move the fields you want to the selected box
- Check Unique Index
- Click Create Index
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 06:15 AM
you can create field values based on a calculated value.
On the Dictionary Entry for the attribute, you can make it a Calculated Value to combine 2 fields or something similar.