You need to sign in to do that
Don't have an account?

Making the User Object standard field Unique.
Hi all,
I have a situation where, the Standard Field 'Extension' of User Object needs to be Unique.
Is there any way I can make this field unique.
Any help regarding this would be highly appreciated.
Thanks in Advance,
Mohammed Uzair.
Your trigger should like this :
I hope this will help you.
All Answers
I think we cannot make a standard field unique.
There is one alternative solution. Create a custom field on User, make that unique. Write a trigger on User to update that field with Extension. If there is a duplicate value in Extension, trigger will try to copy it to your custom field and will throw error.
Thanks,
Sonali
Hi
I used Trigger for Making the field Unique
see the below code
trigger ExtesionTrigger on User (before insert)
{
list <User> u1 = new List <User>();
u1 = [select Extension from User];
if(Trigger.isInsert)
{
For(integer i=0;i<u1.size();i++)
{
for(User u2 : Trigger.New)
{
if(u1[i].Extension == u2.Extension)
{
u2.Extension.addError('Trigger Error::This value already Exist');
}
}
}
}
}
I think it will be usefull for you
Thanks!
Your trigger should like this :
I hope this will help you.
@Shashikant Sharma In the case of edit the record trigger will be fail.