+ Start a Discussion
john8407john8407 

Help with Trigger

Im working on a trigger to assign a case to the account owner if the type is 3 of the 6.  Say if I have case types below. 

 

Type1

Type2

Type3

Type4

Type5

Type6

 

I want it to be assigned to account owner if the case type is the first 3.  I cant figure out how to list multiple values in the trigger.  Below is how I have it now.

 

//change owner to account owner

if (c.Type == 'Type1', 'Type2', 'Type3') {

for (Account a : lAccounts) {

if (c.AccountId == a.Id) {

c.OwnerId = a.OwnerId;

JimRaeJimRae

Use the Or operator "||".

 

 

//change owner to account owner

if (c.Type == 'Type1'|| c.Type =='Type2'|| c.Type =='Type3') {

for (Account a : lAccounts) {

if (c.AccountId == a.Id) {

c.OwnerId = a.OwnerId;

 

 

john8407john8407

That worked! Thank you very much! Another question if you dont mind.  Is there a way to make the email notification go out when the case is assigned by this trigger? I have the assignment rules for other case types which go to queues but I had to use the trigger for the case types that should be assigned to the account owner. 

 

Also, I guess now I have to instruct users to not check the assign using active assignment rules on these types or is that incorrect? I dont have these case types in the assignment rules.  Will the trigger still work if they do check the box and these case types are not in the rules?