How to determine if case owner is queue with specific developer name
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}
up vote
2
down vote
favorite
I have a problem with selecting specific custom queue in apex code.
For example I have:
Case c = (Case) controller.getRecord();
String queueName = c.Owner.Name;
if (queueName != 'ATM_queue') {
//DO SOMETHING
}
Thanks for any advice.
apex queue
add a comment |
up vote
2
down vote
favorite
I have a problem with selecting specific custom queue in apex code.
For example I have:
Case c = (Case) controller.getRecord();
String queueName = c.Owner.Name;
if (queueName != 'ATM_queue') {
//DO SOMETHING
}
Thanks for any advice.
apex queue
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a problem with selecting specific custom queue in apex code.
For example I have:
Case c = (Case) controller.getRecord();
String queueName = c.Owner.Name;
if (queueName != 'ATM_queue') {
//DO SOMETHING
}
Thanks for any advice.
apex queue
I have a problem with selecting specific custom queue in apex code.
For example I have:
Case c = (Case) controller.getRecord();
String queueName = c.Owner.Name;
if (queueName != 'ATM_queue') {
//DO SOMETHING
}
Thanks for any advice.
apex queue
apex queue
asked yesterday
David
477
477
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
8
down vote
accepted
There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it:
if(c.ownerid.getsobjecttype() == Group.SobjectType) {
Group queue = [select developername from group where id = :c.ownerid];
if(Queue.DeveloperName == 'atm_queue') {
As an alternative, you could also create a formula field to return the value, something like owner:queue.developername
, and then you can check that value instead.
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
add a comment |
up vote
1
down vote
I'm not sure if you specifically need Developer Name or if you can use friendly name instead, but the Owner.Name field is populated when the Owner is a queue - but it uses the display name. So if your queue is called "ATM Queue" then the Owner.Name will be ATM Queue and your if statement would be:
if(queueName != 'ATM Queue'){
// Do Something
}
Additionally, to make sure that the owner IS a queue before you assign the queueName string, you should do a Owner Check to see if the Owner is a User or a queue, like this:
String queueName;
String ownerId;
Case c = (Case) controller.getRecord();
ownerId = c.OwnerId;
if(String.valueOf(ownerId).startsWith('00G')){
queueName = c.Owner.Name;
}
if (queueName != 'ATM Queue') {
//DO SOMETHING
}
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.
– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it:
if(c.ownerid.getsobjecttype() == Group.SobjectType) {
Group queue = [select developername from group where id = :c.ownerid];
if(Queue.DeveloperName == 'atm_queue') {
As an alternative, you could also create a formula field to return the value, something like owner:queue.developername
, and then you can check that value instead.
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
add a comment |
up vote
8
down vote
accepted
There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it:
if(c.ownerid.getsobjecttype() == Group.SobjectType) {
Group queue = [select developername from group where id = :c.ownerid];
if(Queue.DeveloperName == 'atm_queue') {
As an alternative, you could also create a formula field to return the value, something like owner:queue.developername
, and then you can check that value instead.
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
add a comment |
up vote
8
down vote
accepted
up vote
8
down vote
accepted
There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it:
if(c.ownerid.getsobjecttype() == Group.SobjectType) {
Group queue = [select developername from group where id = :c.ownerid];
if(Queue.DeveloperName == 'atm_queue') {
As an alternative, you could also create a formula field to return the value, something like owner:queue.developername
, and then you can check that value instead.
There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it:
if(c.ownerid.getsobjecttype() == Group.SobjectType) {
Group queue = [select developername from group where id = :c.ownerid];
if(Queue.DeveloperName == 'atm_queue') {
As an alternative, you could also create a formula field to return the value, something like owner:queue.developername
, and then you can check that value instead.
answered yesterday
sfdcfox
240k10182401
240k10182401
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
add a comment |
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
+1 for formula field as it saves queries, Downside(Only 20 object references on a case and that can be bit tricky)
– Pranay Jaiswal
yesterday
add a comment |
up vote
1
down vote
I'm not sure if you specifically need Developer Name or if you can use friendly name instead, but the Owner.Name field is populated when the Owner is a queue - but it uses the display name. So if your queue is called "ATM Queue" then the Owner.Name will be ATM Queue and your if statement would be:
if(queueName != 'ATM Queue'){
// Do Something
}
Additionally, to make sure that the owner IS a queue before you assign the queueName string, you should do a Owner Check to see if the Owner is a User or a queue, like this:
String queueName;
String ownerId;
Case c = (Case) controller.getRecord();
ownerId = c.OwnerId;
if(String.valueOf(ownerId).startsWith('00G')){
queueName = c.Owner.Name;
}
if (queueName != 'ATM Queue') {
//DO SOMETHING
}
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.
– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
add a comment |
up vote
1
down vote
I'm not sure if you specifically need Developer Name or if you can use friendly name instead, but the Owner.Name field is populated when the Owner is a queue - but it uses the display name. So if your queue is called "ATM Queue" then the Owner.Name will be ATM Queue and your if statement would be:
if(queueName != 'ATM Queue'){
// Do Something
}
Additionally, to make sure that the owner IS a queue before you assign the queueName string, you should do a Owner Check to see if the Owner is a User or a queue, like this:
String queueName;
String ownerId;
Case c = (Case) controller.getRecord();
ownerId = c.OwnerId;
if(String.valueOf(ownerId).startsWith('00G')){
queueName = c.Owner.Name;
}
if (queueName != 'ATM Queue') {
//DO SOMETHING
}
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.
– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
add a comment |
up vote
1
down vote
up vote
1
down vote
I'm not sure if you specifically need Developer Name or if you can use friendly name instead, but the Owner.Name field is populated when the Owner is a queue - but it uses the display name. So if your queue is called "ATM Queue" then the Owner.Name will be ATM Queue and your if statement would be:
if(queueName != 'ATM Queue'){
// Do Something
}
Additionally, to make sure that the owner IS a queue before you assign the queueName string, you should do a Owner Check to see if the Owner is a User or a queue, like this:
String queueName;
String ownerId;
Case c = (Case) controller.getRecord();
ownerId = c.OwnerId;
if(String.valueOf(ownerId).startsWith('00G')){
queueName = c.Owner.Name;
}
if (queueName != 'ATM Queue') {
//DO SOMETHING
}
I'm not sure if you specifically need Developer Name or if you can use friendly name instead, but the Owner.Name field is populated when the Owner is a queue - but it uses the display name. So if your queue is called "ATM Queue" then the Owner.Name will be ATM Queue and your if statement would be:
if(queueName != 'ATM Queue'){
// Do Something
}
Additionally, to make sure that the owner IS a queue before you assign the queueName string, you should do a Owner Check to see if the Owner is a User or a queue, like this:
String queueName;
String ownerId;
Case c = (Case) controller.getRecord();
ownerId = c.OwnerId;
if(String.valueOf(ownerId).startsWith('00G')){
queueName = c.Owner.Name;
}
if (queueName != 'ATM Queue') {
//DO SOMETHING
}
answered yesterday
Morgan Marchese
1,423426
1,423426
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.
– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
add a comment |
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.
– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
4
4
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.– sfdcfox
yesterday
if(c.OwnerId.getSobjectType() == Group.SobjectType)
is more self-documenting instead of relying on the key prefix.– sfdcfox
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
I actually didn't even know that you could use .getSObjectType() in that context, that's very good information, thanks!
– Morgan Marchese
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f239851%2fhow-to-determine-if-case-owner-is-queue-with-specific-developer-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown