You need to sign in to do that
Don't have an account?
surendra kumar 7
trigger duplicatename
im write the trigger duplicate name on student object its show an error
Error :required (...)+ loop did not match anything at input 'trigger'
trigger duplicatename on student__c (before insert)
{
list<student__c> stlist=trigger.new;
list<student__c> stnewlist=new list<student__c>();
for(student__c st:stlist)
{
stnewlist=[select id,name from student__c where name=st.name];
if(stnewlist.size()>0)
{
st.adderror('you cant insert a record with duplicate name');
}
}
}
Error :required (...)+ loop did not match anything at input 'trigger'
trigger duplicatename on student__c (before insert)
{
list<student__c> stlist=trigger.new;
list<student__c> stnewlist=new list<student__c>();
for(student__c st:stlist)
{
stnewlist=[select id,name from student__c where name=st.name];
if(stnewlist.size()>0)
{
st.adderror('you cant insert a record with duplicate name');
}
}
}
I wrote below code for you:
Hope this helps buddy!
PS: if this answers your question then hit Like and mark it as solution!