Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How to: Make Person Searchcode unique

Highlighted
George M. Meneg
Honored Contributor

How to: Make Person Searchcode unique

Hello people,

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

I know 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

Happy hacking!

THIS DOES NOT WORK on v5 since on V5 you cannot type on the field on DB/UI rules.
menes fhtagn
10 REPLIES
George M. Meneg
Honored Contributor

Re: How to: Make Person Searchcode unique

Forum is problematic! this post does not appear in the page!
menes fhtagn
Ashly A K
Honored Contributor

Re: How to: Make Person Searchcode unique

mmmm...Cool..great and thanx a TON for sharing this info!!!

-Ashly
http://www.geocities.com/helponhpopenview
Terry A. Moir
Esteemed Contributor

Re: How to: Make Person Searchcode unique

George, you've got waaaaay too much time on your hands :>)

Seriously though, thanks for sharing - it's something we've been looking for a long time, so we'll give it a try.

Terry
Kashif Masood_1
Regular Collector

Re: How to: Make Person Searchcode unique

Hello,

We tried the suggested method, however, it did not worked. We have SD4.5 SP20. Any Advices ? Regards, Kashif
George M. Meneg
Honored Contributor

Re: How to: Make Person Searchcode unique

Hello Kashif,

What part didn't work? Because I use this trick (also in SP20) and here works like expected.
menes fhtagn
Kashif Masood_1
Regular Collector

Re: How to: Make Person Searchcode unique

Hello George,

Please refer to the attachment where I have taken the screenshots step wise. The part which does not work as suggested is at the end of Rule1 where we are supposed to see

"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]
"


Please advice and thanks for your help, Kashif.
George M. Meneg
Honored Contributor

Re: How to: Make Person Searchcode unique

Hello,

The error is on the step "The â Temp Person;Search code set to [Search code]â is selected and â Removeâ is pressed"

You need to double click this action in order to edit it. Then, on the input box under the "Fields" button select the ;Search code part and press Delete. Then Press Cancel.
menes fhtagn
Raman Shcharbak
Frequent Visitor

Re: How to: Make Person Searchcode unique

George, and what will happen if there are already two persons in SD with the same searchcode and you try to add the third one again with the same searchcode? Will temp_person be filled with first found value? or it will stay empty or generate some error?
George M. Meneg
Honored Contributor

Re: How to: Make Person Searchcode unique

Hello,

The latter. It will generate an error on the log and will leave the temp_person empty.
menes fhtagn
George M. Meneg
Honored Contributor

Re: How to: Make Person Searchcode unique

As Roman observed, this trick requires that no duplicate entries exist. This will fail if the searchcode is already used by more than two persons.
menes fhtagn
//Add this to "OnDomLoad" event