You need to sign in to do that
Don't have an account?
Brend
How to solve this trigger issue
Trigger is working for all profiles instead of only this profile id. Please how do I correct this
trigger accountdelet on Acount (before delete)
{
String ProfileId = UserInfo.getProfileId();
for (Account a : Trigger.old)
IF(ProfileId!='00721100046VB5L')
{
a.addError('Not permitted');
}
}
trigger accountdelet on Acount (before delete)
{
String ProfileId = UserInfo.getProfileId();
for (Account a : Trigger.old)
IF(ProfileId!='00721100046VB5L')
{
a.addError('Not permitted');
}
}
I think UserInfo.getProfileId() is giving 18 digit profile id, so for IF(ProfileId!='00721100046VB5L') this condition either you should use contains method or should query the profile id basis on profile name instead of hardcoded id.
Thanks
trigger accountdelet on Acount (before delete)
{
String ProfileId = UserInfo.getProfileId();
for (Account a : Trigger.old)
IF(ProfileId != [select id from profile where id = '00721100046VB5L' LIMIT 1])
{
a.addError('Not permitted');
}
}
I think this will work correctly.
I even tried and converted the profile id to 18 digits and it is still givng same error
use below one :
trigger accountdelet on Account (before delete) {
String ProfileId = UserInfo.getProfileId();
for (Account a : Trigger.old)
IF(ProfileId != [select id from profile where id = '00721100046VB5L' LIMIT 1].Id) {
a.addError('Not permitted');
}
}
Below code can fulfill your requirements. Hope this will work for you. Please mark this as best answer if this solves your problem.
Thank you
Ajay Dubedi