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
Bharat Chandra MohantyBharat Chandra Mohanty 

prevent Duplication record save based on 2 field

I have created a lightning Web component that accepts input from user and saves the data to the custom setting. Now i want to check duplication of the record based on two fields. Let suppose Name and Contact, i.e if Name and Contact together of the current record is is same as any other existing record then it should not be saved.
How do i handle that in apex And JavaScript?

Thanks In Advance
Vinay MVinay M

Hi Barat,

    You will need Apex to get all values from the Custom setting and compare Name and Contact while creating the custom setting entry from LWC and do not allow creating a new entry when they match. In your JS method which handles the creation of entry for custom setting, you can compare the values obtained from Apex, and display an error message. If it does not match, then continue with creation of entry.

 

Thank you,

Vinay.

Bharat Chandra MohantyBharat Chandra Mohanty
Thank You ,I have did the same and it is working