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
Everton CP7Everton CP7 

Just owner's case

I created a trigger to not let anyone close the case, unless you're the owner.

 

The problem is that some of my cases are created to queues.

 

How I add in my trigger the queues too?

 

trigger ProprietarioFechaChamado on Case (after update) {

    for(Case c : Trigger.new){
    if (c.Status == 'Fechado' && c.OwnerId <> UserInfo.getUserId()) {
      c.addError ('Erro');
}
    }
}

 

Thanks !

Vinit_KumarVinit_Kumar

Everton,

 

What you want to do with the cases whwre Queue is the owner,do you want to get it closed or want to throw an error.Please elaborate your requirement.

Everton CP7Everton CP7

Thanks Vinit !

The trigger works fine.

 

I'll give you a example:
I'm user "Everton", if the owner's case is "Everton", I can close the case. If another users try to close will give him my trigger error.
But I'm part of a queue, called "Queue Everton".
If the owner's case is "Queue Everton" I still have to close the case. But it's giving me my trigger error.

 

Cause my trigger only works with UserID.

 

What I need is to include Queues in my trigger too.

So I want to get it closed.

Vinit_KumarVinit_Kumar

Everton,

 

You should be querying on queue object and see if the user is part of queue,then it should not throw an error and allow you to close it.

 

 

Everton CP7Everton CP7

Thanks !

Yeah.

I know in theory but I can't do it when I will put in practice.

 

Can you help me?