diff --git a/resources/queries/snd/LookupSets.query.xml b/resources/queries/snd/LookupSets.query.xml
new file mode 100644
index 00000000..65b07f1a
--- /dev/null
+++ b/resources/queries/snd/LookupSets.query.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ SetName
+
+
+ true
+
+
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/queries/snd/LookupSets/.qview.xml b/resources/queries/snd/LookupSets/.qview.xml
new file mode 100644
index 00000000..02898e37
--- /dev/null
+++ b/resources/queries/snd/LookupSets/.qview.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/queries/snd/Lookups.js b/resources/queries/snd/Lookups.js
index 36408406..177cebbb 100644
--- a/resources/queries/snd/Lookups.js
+++ b/resources/queries/snd/Lookups.js
@@ -45,11 +45,6 @@ function beforeUpdate(row, errors) {
}
function beforeDelete(row, errors) {
-/*
- TODO: Need a better way to determine if a lookupset item is in use. Probably need to add the check to
- the deleteRows method in LookupsTable.java. NOTE: CAMP allows the lookup item to be deleted if it hasn't
- been assigned as a default value or used in an event. tjh
- */
if (row.LookupSetId !== undefined) {
let lookupQuery
@@ -81,18 +76,17 @@ function beforeDelete(row, errors) {
LABKEY.Query.selectRows({
schemaName: 'snd',
- queryName: 'PackageAttribute',
- columns: 'LookupQuery',
+ queryName: 'Lookups',
+ columns: 'IsInUse',
scope: this,
filterArray: [
- LABKEY.Filter.create('LookupQuery', lookupQuery, LABKEY.Filter.Types.EQUAL),
- LABKEY.Filter.create('LookupSchema', 'snd', LABKEY.Filter.Types.EQUAL)
+ LABKEY.Filter.create('LookupId', row["LookupId"], LABKEY.Filter.Types.EQUAL),
+ LABKEY.Filter.create('IsInUse', 'true', LABKEY.Filter.Types.EQUAL)
],
success: function (data) {
if (data.rows && data.rows.length) {
- errors._form = 'Lookup item cannot be deleted - LookupSet is in use.'
- return;
+ errors._form = 'Lookup item cannot be deleted - Lookup is in use.'
}
},
failure: function (error) {
diff --git a/resources/queries/snd/Lookups.query.xml b/resources/queries/snd/Lookups.query.xml
index c08dfb5c..c4b5d0b1 100644
--- a/resources/queries/snd/Lookups.query.xml
+++ b/resources/queries/snd/Lookups.query.xml
@@ -3,6 +3,17 @@
Value
+
+
+ true
+
+
+ true
+
+
+ true
+
+
diff --git a/resources/queries/snd/Lookups/.qview.xml b/resources/queries/snd/Lookups/.qview.xml
new file mode 100644
index 00000000..6dec6876
--- /dev/null
+++ b/resources/queries/snd/Lookups/.qview.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/schemas/dbscripts/sqlserver/snd-23.001-23.003.sql b/resources/schemas/dbscripts/sqlserver/snd-23.001-23.003.sql
new file mode 100644
index 00000000..09295734
--- /dev/null
+++ b/resources/schemas/dbscripts/sqlserver/snd-23.001-23.003.sql
@@ -0,0 +1,2 @@
+CREATE UNIQUE INDEX IDX_LookupSets_SetName
+ON snd.LookupSets (SetName)
\ No newline at end of file
diff --git a/src/org/labkey/snd/SNDManager.java b/src/org/labkey/snd/SNDManager.java
index 3a0077e9..16edff8c 100644
--- a/src/org/labkey/snd/SNDManager.java
+++ b/src/org/labkey/snd/SNDManager.java
@@ -3380,5 +3380,5 @@ public List