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

Using a Like statement within if a trigger issue
I would like to use a if statement in a trigger that checks if the User Profile is like 'ABC Customer Portal'. The following snippet doesn't like the use of the 'Like' keyword. I have also tried ' += ' but that results in a error that 'And can be used only with boolean expressions'.
What is the proper syntax for using a like contition withn a If statement?
Regards,
String pf = u.ProfileId; Profile pfName = [select Name from profile where id = :pf]; String UserId = u.Id; if (contactId!=null && contactId!='' && (pfName.Name LIKE '%ABC Customer Portal%')) { . . . }
Try the contains String method instead:
String pf = u.ProfileId; Profile pfName = [select Name from profile where id = :pf]; String UserId = u.Id; String profName = pfName.Name; String abcPortal = 'ABC Customer Portal'; if (contactId!=null && contactId!='' && profName.contains(abcPortal)) { . . . }
All Answers
Try the contains String method instead:
String pf = u.ProfileId; Profile pfName = [select Name from profile where id = :pf]; String UserId = u.Id; String profName = pfName.Name; String abcPortal = 'ABC Customer Portal'; if (contactId!=null && contactId!='' && profName.contains(abcPortal)) { . . . }