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
James Kacerguis 5James Kacerguis 5 

Best way to get single Queue ID and assign as owner?

I currently have apex class in lightning component that is getting a specific Queue Id to assign as owner of the record the component is launched from.

This is the current  way I'm getting the id, but I'm guessing there is a better way to do this, any ideas?
Group marketingQueue = [SELECT id,Name FROM Group WHERE Type = 'Queue' and DeveloperNAME = 'MarketingProspectLeads'];
         	ID marketingQueueId = marketingQueue.id;
            //l.OwnerId = UserInfo.getUserId();
            system.debug('marketingQueue');
            l.OwnerId = marketingQueueId;

I just need to make sure this can't break so I'm assuming I should add some error checking or be doing this a different way.  Thanks in advance.  
Best Answer chosen by James Kacerguis 5
Sonali_takkeSonali_takke
Hi James,
If you don't require Name then you can modify your query as follows to reduce number of lines in code and add NULL check before assignment to avoid code break.
 
ID marketingQueueId = [SELECT id FROM Group WHERE Type = 'Queue' and DeveloperNAME = 'MarketingProspectLeads'].Id;

if(marketingQueueId != NULL) {
    l.OwnerId = marketingQueueId;
}

Kindly mark as resolved if you find this anser helpful. 

All Answers

anshul saini 7anshul saini 7
Hi James,
You can add 'Limit 1' in your query for for single id. as
Group marketingQueue = [SELECT id,Name FROM Group WHERE Type = 'Queue' and DeveloperNAME = 'MarketingProspectLeads' limit 1];
Sonali_takkeSonali_takke
Hi James,
If you don't require Name then you can modify your query as follows to reduce number of lines in code and add NULL check before assignment to avoid code break.
 
ID marketingQueueId = [SELECT id FROM Group WHERE Type = 'Queue' and DeveloperNAME = 'MarketingProspectLeads'].Id;

if(marketingQueueId != NULL) {
    l.OwnerId = marketingQueueId;
}

Kindly mark as resolved if you find this anser helpful. 
This was selected as the best answer
James Kacerguis 5James Kacerguis 5
Great, 
As this component is launched without any user input, I didn't know if there was something I should pass back to the controller to notify the user in case something didn't work.  Thanks for all the feedback. 
Akash Deb NathAkash Deb Nath
Hey, its really amazing blog I am very much interested. Thanks for the great article, Regards UP Ration Crad (https://www.godigitalzone.in/up-ration-card-list/)
helin jessihelin jessi
For new registration: Please go to the Apply Online section of this website and read the instructions carefully before proceeding.
http://student-login.xyz/
Alessia BrookAlessia Brook
Download PowerDirector Pro Apk (https://apkmodpro.co/powerdirector-pro-apk/) No Watermark. Get all the premium features free of cost. More Latest mod Apk (https://apkmodpro.co/) here
Pagal WorldPagal World
This is the best article i ever read on Pagalworld com pagalworld (https://pagalworld.to/) site not only this site i also prefer to visit:  Katmoviehd (https://katmoviehd.world/) movie downloading site where you will get another site is twitter video downloader (https://twittervideodownloader.me/) free tweet save online or download youtube thumbnail (https://youtubethumbnaildownloader.net/) or  convert 2mp3 (https://convert2mp3.me/) best online tubemate app (https://tubemate.asia/) enjoy all the services,
Alessia BrookAlessia Brook
Download Illisiumart Mod Apk (https://apkmodpro.co/illisiumart-mod-apk/). Get all the premium features free of cost. More Latest mod Apk (https://apkmodpro.co/) here
Roger KartRoger Kart
I faced the same problem and thanks for the answer. You can check my website on how I faced this. Amazon feedback Management (https://salesla.com) System
Pagla WorldPagla World
Yes is gree with this but pagalworld (https://pagalworld.nl/) is far batter for song website.
Alessia BrookAlessia Brook
Download Gif Guru Mod Apk (https://apkmodpro.co/gif-guru-mod-apk/)
Alessia BrookAlessia Brook
Download the latest Brochill Mod Apk (https://apkmodpro.co/brochill-mod-apk/)
Alessia BrookAlessia Brook
Download Screensync Pro Apk (https://apkmodpro.co/screensync-pro-mod/)
Alessia BrookAlessia Brook
steve Jrsteve Jr
swapcoder.com is an online website that allows you to generate Instagram fonts (https://www.swapcoder.com) for bio that you can copy and paste into your Instagram bio. 
steve Jrsteve Jr

check out more than 100+ Instagram fonts (https://www.fontgenerator.co/)for your Instagram bio, names and comment to make your Instagram profile looks cool
Alessia BrookAlessia Brook
Download Arrow Go Mod Apk (https://apkmodpro.co/arrow-go-mod-apk/) to become a fighting legend. Also, download Magicians Apprentice Mod Apk (https://apkmodpro.co/magicians-apprentice-mod-apk/) to do magical war. Similarly, download Stick Hero Fighter Mod Apk (https://apkmodpro.co/stick-hero-fighter-mod-apk/) to become a dragon warrior.
Djpunjab DownloadDjpunjab Download
I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.

Pagalworld Download (https://pagalworldownload.online/)
Mr Jatt  (https://mrjatt.buzz)
Mp3 Song (https://mp3songs.live)
Djpunjab Download (https://dj-punjab.live)
webmusic webwebmusic web
Very nice information know more about webmusic (http://webmusicweb.in/)
Tricksvile ConceptTricksvile Concept
So happy that at last I stumbled upon this post, commenting from:
Tricksvile.com (https://www.tricksvile.com/vinkle-mod-apk/) For Mackiestdon.com
On tricksvile.com you can download your mod apk like: On mackiestdon.com, you can learn how to:
Peter Parker 44Peter Parker 44
Very amazing forum site. I am glad I visited this site. You can download Happy Birthday Wishes in Hindi (https://prowhatsappstatus.com/happy-birthday-wishes-in-hindi/) from this site. Also, you will get Attitude Status in Hindi (https://prowhatsappstatus.com/attitude-status-in-hindi/) for WhatsApp too.
Peter Parker 44Peter Parker 44
Hey there, I visited your blog and loved it. You have many quality content on your blog. I also produce such quality content on My blog (https://apkmodpro.co/). Visit here Mod Apk (https://apkmodpro.co/).
Tricksvile ConceptTricksvile Concept
Hey there, I visited your blog and loved it. You have many quality content on your blog. I also produce such quality content on My Mod APK blog (https://www.tricksvile.com/) Visit here Illisiumart  Mod Apk (https://www.tricksvile.com/illisiumart-mod-apk/)
Angela JollyAngela Jolly
Visit Apkmodpro (https://apkmodpro.co/) for modded apps and games
Tricksvile ConceptTricksvile Concept
Download Abbasi Tv (https://www.tricksvile.com/abbasi-tv-apk-download/) from tricksvile.com
bdown bdownbdown bdown
Very nice information know more about Hind mp3 download (bdown.live)
Poonam DeswalPoonam Deswal
I’ve lived in both cities. Really depends on what you want. New York is a city that you immediately fall for. London is an affection that grows steadily on you over time.

New York is more fast-paced and far denser. It’s more obvious exactly what is open late until 4 a.m. and what isn’t.

London vs New York (https://reddit.myringtone.info/london-vs-new-york/)
Boss MobiBoss Mobi
Thank you very much for providing the information to me.
BossMobi (https://bossmobi.club/" target="_blank) Free Bollywood Mp3 Songs, Hindi Songs, Pop DJ Remix.
 
randhir singh 35randhir singh 35
Tonton Dramas is an interesting drama serial by Malaysian channel Tonton, Tv3, Astro Ria, Astro Prima, and Astro Citra. Tonton Dramas watch online all episodes and download free HD quality videos (https://pagalworldownload.site). Tonton Dramas
Khatri MazaKhatri Maza
If you want to download latest bollywood movies for free so visit: khatrimaza.com (https://khatrimaza.io)
fresh mazafresh maza
freshmaza (https://freshmaza.cc/" target="_blank) is the best place here we provide Latest Bollywood Songs Lyrics, Non-Film Hindi Song Lyrics, and All the Latest Punjabi Songs Lyrics with correct spelling and beautiful quotes images and we also provide the huge collections of Hindi, Urdu poetries and Shayari of some famous poets.
Omar WaqasOmar Waqas
I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.

Whatsapp Quotes Status (https://greetingwishesandcardsimages.com/whatsapp-quotes-status-dp-images/)
Monday Morning Blessings And Prayers (https://greetingwishesandcardsimages.com/monday-morning-blessings-and-prayers/)
Good Evening Images 2020 (https://greetingwishesandcardsimages.com/good-evening-images-2020/)
Unique Christmas Gift Ideas For Him 2020 (https://greetingwishesandcardsimages.com/christmas-gift-ideas-for-him/)
Sunil VaishnavSunil Vaishnav
Download Beelinguapp Mod Apk (https://cracksdroid.com/beelinguapp-mod/)
Sourav AroraSourav Arora
I want to encourage that you continue your great posts, have a nice weekend!
My Websites -- ( Teak Wood Supplier (http://jagdevgroup.in" target="_blank), Pollywood News (https://reduaa.com" target="_blank) )
luke neilluke neil
Great post. I used to be checking constantly this weblog (https://apkarc.com/whatsapp-plus/) and I
am inspired! Very helpful information particularly the
closing section :) I maintain such information much
Rohit Sharma 426Rohit Sharma 426
Popcornflix (https://rohitsharma.co/popcornflix/) shows you all movies you can watch on Netflix, Disney+, Amazon Prime, and 200+ other streaming services.
kaka jidanakaka jidana
The article is about the author's gratitude for the people who have shared their stories through website  We create community, and we remind each other that we are not alone.> visit for celebrity networth (https://networthpower.com/)
kaka jidanakaka jidana
see the latest news and quality articles on celebrity net worth on <a href="https://networthpower.com/">networthpower</a> and also visit this post <a href="https://networthpower.com/">https://networthpower.com/richard-tyler-blevins-ninja-gamer-net-worth/ninja</a> @ networthpower.com (https://networthpower.com/)
 
kaka jidanakaka jidana
more news and celebrity news net worth find out here < ninja (https://networthpower.com/richard-tyler-blevins-ninja-gamer-net-worth/), lebron james (https://networthpower.com/lebron-james-net-worth-wiki-bio-career-spouse/), scottie pippen (https://networthpower.com/scottie-pippen-net-worth-wiki-bio-spouse-career/), courtney stodden (https://networthpower.com/courtney-stodden-net-worth-bio-age-height-weight-spouse-career/), noah wyle (https://networthpower.com/noah-wyle-net-worth-wiki-bio-spouse/), mozzy (https://networthpower.com/mozzy-net-worth-wiki-bio-age-career-wife/), emma kenny, (https://networthpower.com/emma-kenney-net-worth-wiki-bio-age-career/) dl hughley (https://networthpower.com/dl-hughley-net-worth-wiki-bio-profession-spouse-children/), nev schulman (https://networthpower.com/nev-schulman-net-worth-wiki-bio-profession-wife-children/), andy samberg (https://networthpower.com/andy-samberg-net-worth-wiki-bio-agemovies-career-wife/), lil uzi vert (https://networthpower.com/lil-uzi-vert-net-worth-bio-faq-age-height-weight-girlfriend-career/), thomas peterfyy (https://networthpower.com/thomas-peterffy-net-worth-wiki-bio-age-profession-family-children/), spiderman (https://networthpower.com/spider-man-no-way-home-trailer-out-45-million-views-within-hours/), abigail spenecer (https://networthpower.com/abigail-spencer-net-worth-wiki-bio-age-height-spouse-movies-career-education-family-lifestyle-followers-facts/), evan rachel wood (https://networthpower.com/evan-rachel-wood-net-worth-wiki-bio-age-height-husband-movies-career/)
kaka jidanakaka jidana
Το Networthpower (https://networthpower.com)είναι ιστότοπος που δημοσιεύει περιεχόμενο για την καθαρή αξία των διασημοτήτων και τα τελευταία και μοντέρνα θέματα ειδήσεων για δημοφιλείς λαούς. https://networthpower.com/ (http://networthpower.com), https://networthpower.com/, (https://networthpower.com) https://networthpower.com/ (https://networthpower.com), 
aris setiawanaris setiawan
pagalworld free download song and mp3
jhon Vasilenkajhon Vasilenka
all time for easy to fast download from youtube to mp4 and mp4 convertor https://mp3juices.mx/
Sourav AroraSourav Arora
This is a really well-informed and valuable source of information.
packers and movers (http://cityrelocationservices.co.in/)  buy and sell websites (https://actinium.in/)
Sourav AroraSourav Arora
Dr. Sunil Kumar a nephrologist & kidney transplant doctor in Kolkata (https://savekidneys.com/), India. His keen interest is in kidney transplant, Renal replacement therapy