function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jerome ScolaJerome Scola 

About Validation Rule

HI,All.

       Can I create a Validation Rule for the following case? If I can, how to create it? Thanks.

There are  two fields in my custome object : Family and TicketId.    Family has  a,b,c options 
 My requirement is:

    If Family=b, then I want to the TicketId is unique.


Virendra ChouhanVirendra Chouhan
Hi Jerome,

I think you can do this in validation formula field just use If function and put condition family__c == 'b'.
if true then ticketId can't be blank. (Here family__c is picklist right?)

IF( ISPICKVAL( Family__c,'b') , ISNULL(ticketId) , false)
Jerome ScolaJerome Scola
thanks to your reply.
family is picklist , ticketid is number.

I want the TicketId is unique, it doesn't matter if it's null. if there is a ticketId=1,then 1 can't be used for a new product when the family is b
Virendra ChouhanVirendra Chouhan
Hello

Sorry my mistake in read the question. I thought you want to required that field.
anyways for unique the field depend on picklist.I think you have to use trigger.
in trigger just check first the picklist values is 'B' or not.if yes then query on that object with where cause where ticketId = 'bind this with current record's ticketid field'.
and if this list size is grater to 1 it means in data base the same value exist.
so add error on it.

got it?
Jerome ScolaJerome Scola
Thanks.

I didn't find a place to create a trigger. 

I refer to the documentation of this link https://help.salesforce.com/HTViewHelpDoc?id=code_define_trigger.htm&language=en_US
but it was not helpful