function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
john8407john8407 

Trigger Help

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) {

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

This is the answerb you are looking for:-

 

//change owner to account owner

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

for (Account a : lAccounts) {

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

 

where || is the OR operator in Apex.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

 

 

All Answers

Ispita_NavatarIspita_Navatar

This is the answerb you are looking for:-

 

//change owner to account owner

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

for (Account a : lAccounts) {

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

 

where || is the OR operator in Apex.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

 

 

This was selected as the best answer
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?

Ispita_NavatarIspita_Navatar

Yes you can send email in apex trigger but for that you have to use the emailing class. I think it should not interfere.