0

here I just want to check whether my assignment rule is working properly or not, so I have written a trigger, but in trigger I think I am doing something wrong so getting this error--Error: Compile Error: expecting a right parentheses, found '&' at line 13 column 0
, can anyone please help me out.

trigger Testing on Case (after insert) {

List<Profile> PROFILE = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1];
Public String MyProflieName = PROFILE[0].Name;
List<User> Use = new List<User>([SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()]);
for(Case c:Trigger.New)
    {
        for(User u: Use)
        {
            System.Debug(
            (c.RecordType.Name='Client Service')
            &((c.Categories__c !='DCS Client Services')||(c.Categories__c !='DCS Technical Support'))
            &((c.Account_Segmentation__c != 'Z2')||(c.Account_Segmentation__c != 'Z3')||(c.Account_Segmentation__c != 'Z4')||(c.Account_Segmentation__c !=' Z5')||(c.Account_Segmentation__c != 'D1'))
            &((MyProflieName=='DCS Client Services')||(MyProflieName=='DCS Technical Support'))
            &((c.Origin='Email')||(c.Origin='Phone')||(c.Origin='Chat')||(c.Origin='Internal'))
            &(!((u.FirstName='PBI')&(u.LastName='Default')))
            );

        }
    }
}
  • 2
    Are sure you want to use bitwise AND operator? Can you try with &&? – javanoob Feb 29 '16 at 4:26
  • Just make your & as && instead. – Kaushik Ray Feb 29 '16 at 4:57
2

You should use && instead of & for joining two logical conditions.
So, your code should look like something this:

List<Profile> PROFILE = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1];
Public String MyProflieName = PROFILE[0].Name;
List<User> Use = new List<User>([SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()]);
for(Case c:Trigger.New)
    {
        for(User u: Use)
        {
            System.Debug(
            (c.RecordType.Name='Client Service')
            &&((c.Categories__c !='DCS Client Services')||(c.Categories__c !='DCS Technical Support'))
            &&((c.Account_Segmentation__c != 'Z2')||(c.Account_Segmentation__c != 'Z3')||(c.Account_Segmentation__c != 'Z4')||(c.Account_Segmentation__c !=' Z5')||(c.Account_Segmentation__c != 'D1'))
            &&((MyProflieName=='DCS Client Services')||(MyProflieName=='DCS Technical Support'))
            &&((c.Origin='Email')||(c.Origin='Phone')||(c.Origin='Chat')||(c.Origin='Internal'))
            &&(!((u.FirstName='PBI')&&(u.LastName='Default')))
            );

        }
    }
}
  • 2
    Last part of debug : &&(!((u.FirstName='PBI') && (u.LastName='Default')) – Saumya Ranjan Satapathy Feb 29 '16 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.