Make Person Search code unique

Thanks to author :  George M. Menegakis


How to do :

Did you wish to make Person;Searchcode unique without messing around with the DB indexes?

There is a "workaround" to run sd_dataform listing all persons with same searchcode but this cannot enforce uniqueness of searchcode, is merely a warning.

Well, it is doable :)

I don't recall if there is a custom person field in persons. If yes you can use that, if not, you need SP19 or higher to create a custom person field.

It takes two UI rules. First enable the custom person field and name it whatever, (eg: temp_person).

1st Rule:

When searchcode is anything set temp_person;searchcode to searchcode.

Now the tricky part.

Before saving the rule, open the update data panel and select the entry you entered previously. Select with the mouse the ";searchcode" part and press delete. You will notice that "Value" is cleared. Don't worry, just press CANCEL.

The interesting part that if you followed the steps exactly the rule is now:

When a value has changed
where Searchcode (*) is anything
AND LDAP_DN is empty
SET REPORTS;TO SEARCHCODE (Update Data) temp_person set to [Searchcode]

Cool huh? The good thing is that if searchcode matches an existing person then the custom field temp_person will be filled! If not, it will remain empty.

Now the second rule is very simple. Before item is saved where temp_person is not empty present a message of ERROR type (so the user cannot cancel and save the record).

This trick is actually based on the bug discovered and exploited first time by Oguz Kutlu Asik at this post:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=787798

THIS DOES NOT WORK on v5 since on V5 you cannot type on the field on DB/UI rules.

Original Post  can be find at :

 

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1119853.