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

Good Afternoon!!
I have a lightning page and the data in that page got mapped to the custom object's corresponding fileds. Now my requirement is the data in that lightning page should not allow duplicates. For that I need to add a key to the code to check if the data is already existing or new one. If already existing then we should not allow that duplicate record in the lightning page.
I don't really know how to crack this. Please help me with the inputs.
I don't really know how to crack this. Please help me with the inputs.
You can write a trigger on before update and check new and old values.
e.g. suppose on account object
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map <String, Schema.SObjectField> fieldMap = schemaMap.get('Account ').getDescribe().fields.getMap();
for(Account acc : Trigger.new){
for(Schema.SObjectField sfield : fieldMap.Values()){
schema.describefieldresult dfield = sfield.getDescribe();
String apiName = dfield.getType ();
if(acc.get(apiName ) == Trigger.oldMap.get(apiName )){
acc.addError('Duplicate value found on field->'+ dfield.getLabel ());
}
}
}
Hope this will help you.
Please mark as best answer is helpful.
Thanks