tag:blogger.com,1999:blog-1716073687404477810.post3132018960306517544..comments2024-03-29T00:05:45.563-07:00Comments on Technology Share - TechShare: Too many SOQL queries: 21Aslam - The Alexendrahttp://www.blogger.com/profile/09450719086908671499noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-1716073687404477810.post-58387209019595955882010-05-03T00:17:16.657-07:002010-05-03T00:17:16.657-07:00Nice post Aslam !
Its good to see utilization of...Nice post Aslam ! <br /><br />Its good to see utilization of static context in this way, as you said execution thread is same for all triggers. Using Schema.SObjectType.Case.getRecordTypeInfos() is equally good if we cache the results similarly in some static context to save further describe calls.Abhinav Guptahttps://www.blogger.com/profile/02464576868898888254noreply@blogger.comtag:blogger.com,1999:blog-1716073687404477810.post-13006327173458197252010-04-30T00:21:04.902-07:002010-04-30T00:21:04.902-07:00Aslam,
For this specific scenario, wouldn't ...Aslam, <br /><br />For this specific scenario, wouldn't it be nicer to rather just leverage the API call to get recordtypeInfos and then use the getRecordTypeId() method to get the specific one....Anonymoushttps://www.blogger.com/profile/14469884503101044074noreply@blogger.comtag:blogger.com,1999:blog-1716073687404477810.post-17872844357467906412010-04-22T12:08:30.764-07:002010-04-22T12:08:30.764-07:00@Jeff:- Thanks for pointing out the typo mistake. ...@Jeff:- Thanks for pointing out the typo mistake. I fixed it.<br /><br />@Tom:- Its good to know more about RecordTypeInfos(). Thanks for sharing.Aslam - The Alexendrahttps://www.blogger.com/profile/09450719086908671499noreply@blogger.comtag:blogger.com,1999:blog-1716073687404477810.post-44563289084035573822010-04-22T07:28:23.862-07:002010-04-22T07:28:23.862-07:00You can also save some SOQL queries by using Descr...You can also save some SOQL queries by using Describe information.<br /><br />Schema.SObjectType.Case.getRecordTypeInfos() will return all the RecordTypes for the case as RecordTypeInfo objects.<br /><br />There are governor limits on RecordTypeInfo-related calls, but you can at least divert some SOQL calls away to free them up.Tom Patroshttp://www.twitter.com/tompatrosnoreply@blogger.comtag:blogger.com,1999:blog-1716073687404477810.post-82104927842649969302010-04-22T06:32:50.654-07:002010-04-22T06:32:50.654-07:00Aslam, I think the code above has a typo as it thr...Aslam, I think the code above has a typo as it throws an error for me. It looks like the blog stripped out the left and right brackets. I think<br /><br />Map mapRecordTypes = = new Map([SELECT Id, Name from RecordType WHERE SObjectType = 'Case']);<br /><br />Should be replaced with<br /><br />Map<ID,RecordType> mapRecordTypes = new Map<ID,RecordType>([SELECT Id, Name from RecordType WHERE SObjectType = 'Case']);Jeff Douglashttps://www.blogger.com/profile/06244960476714752288noreply@blogger.com