Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
16 replies
Subscribers
10 subscribers
Views
9170 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Uniqueness of a field
sergeiz1
over 8 years ago
Hello!
What is the best way to keep some CDT field unique? It will be a constraint in the database, but the database error message is not user friendly.
I can set it up as a query rule or expression and validate manually in the interface. In this case the designer should remember what fields have to be validated.
May be there is an easier and straightforward way to achieve it?
OriginalPostID-273384
Discussion posts and replies are publicly visible
0
Stefan Helzle
A Score Level 3
over 8 years ago
You could create a special SAIL component for this kind of value that already includes the validation. So a designer will not be able to forget it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sergeiz1
over 8 years ago
And the validation itself still should be manual?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sergeiz1
over 8 years ago
With database constraint the error message will appear in the Alerts and user will not see it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Two possible ways:
1) Add a validation which checks by querying database if the entered value already exists in DB. Problem is that another user could enter the same value at this time and the check would be OK for both.
2) Directly write the data to DB in the saveInto (a!writeToDatastoreEntity()) and react on failure/success of the operation. This way two users cannot enter the same value at the same time.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sergeiz1
over 8 years ago
Thanks!
From my point of view option 1 is preferable in conjunction with database constraint. Option 2 is harder to insert into some process with additional error handling.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
You could also validate just before the database write, and return to the form if the value is no longer unique.
I'm curious as the requirement though - why would a user need to enter a value that must be unique? Is it a name of some sort?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Option 2 is actually not that hard to implement directly in SAIL and would be best out of a user perspective. You also would not need to handle errors in DB.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Sorry: You also would not need to handle errors in DB. -> You also would not need to handle errors in process
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
Another thought - if the row already exists and you're feeling ambitious, you could implement pessimistic locking. What Stefan has suggested is already a sort of optimistic locking, i guess! :)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sergeiz1
over 8 years ago
How can answer to someone on this forum? It's hard to understand talking to several people where are answers to me.
> I'm curious as the requirement though - why would a user need to enter a value that must be unique? Is it a name of some sort?
It's a pretty common requirement for an object name to be unique.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>