+ Start a Discussion
Kumar GKumar G 

How to restrict the duplicate child record creation

Opportunity(Standard Object) and Profile(Custom Object) having master detail relationship , 

Profile object is having an picklist field called Year with the values like 2020,2021,2022... 
  Opportunity Name     Profile : Year
Allow : OPP1                :2020
            OPP1               :2021
Diffrent years should associated with the same Opportunity.

Don't Allow : OPP1      :2020
                     OPP1      :2020
Same year should not associated to the same Opportunity.

Need to through an validation while saving the duplicate Profile record with the same year to the same opportunity.

Please let me know can we achieve this throgh custom LWC ?

Kindly suggest me wit hyour solutions.Thanks in advance.

ShirishaShirisha (Salesforce Developers) 
Hi Kumar,


You need to use the custom controller to query the Object to see,if there is any record with the value of 2020 if it returns null then they can use the value.

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Shirisha Pathuri