Some time you need to prevent creation of duplicates records for Example on Contact Business Component you have 1 record with FirstName-Pratibha and you want if anybody create or insert record having same FirstName-Pratibha then its give error "You cannot add same name to more than 1 time" for this type of requirement we need to use "BCHasRows" property , Please follow the following steps to implement this property:-
1.Create a calculated field on “Contact” BC:
a. Name = Duplicate Firstname Calc
b. Calculated = True
c. Calculated Value =
BCHasRows("Contact", "Contact", "[First Name] = '"+[First Name]+"'"+"AND [Row Id] <> '"+[Row Id]+"'" , "All")
2. Put the validation on “FirstName" field :
a. Validation =
[Duplicate Firstname Calc] = 'N'
b. Validation Message – String Override =
"You cannot add same name to more than 1 time"
3- Compile Contact Business Component and test it.
1.Create a calculated field on “Contact” BC:
a. Name = Duplicate Firstname Calc
b. Calculated = True
c. Calculated Value =
BCHasRows("Contact", "Contact", "[First Name] = '"+[First Name]+"'"+"AND [Row Id] <> '"+[Row Id]+"'" , "All")
2. Put the validation on “FirstName" field :
a. Validation =
[Duplicate Firstname Calc] = 'N'
b. Validation Message – String Override =
"You cannot add same name to more than 1 time"
3- Compile Contact Business Component and test it.
Prevent Creation of duplicate records
ReplyDeleteUsefull
ReplyDelete