Populating an inner List in a Map

Center Blog
Populating a inner List in a Map collection A simple way to populate a list that inside a map collection could be done like this. You can run that piece of code in your developer console. [code lang="php"] /********************************************************************** * * Populating a List inside a Map collection * ************************************************************************/ List<Account> acclist = [SELECT Id, Name, (SELECT Id, lastName FROM Contacts) FROM Account LIMIT 50]; // This map will be contain the list of contacts as values and the // account ids as key. Map<Id,List<Contact>> accConMap = new Map<Id,List<Contact>>(); for(account acc : acclist) { List<Contact> innerList = new List<Contact>(); for(contact c: acc.contacts) innerList.add(c); accConMap.put(acc.id, innerList); } // accConMap.put(acc.Id, innerList) will insert key and values to our map // [/code] As you can see it is quite simple. All you need…
Read More

Aborting Apex Jobs

Center Blog
Aborting Apex Jobs THere is a way to abort Apex Jobs that can be easily acomplish from the developer console. If you open an anonymous window in your developer console you can use the following SOQL. [code lang="html"] /*************************************************************************** * * Running this SOQL in an anonymous window will get information about all * active apex jobs in your org. * ****************************************************************************/ List<CronTrigger> crontList = [SELECT CreatedById, CreatedDate, CronExpression, CronJobDetailId, EndTime,Id, LastModifiedById,NextFireTime, OwnerId, PreviousFireTime, StartTime, State, TimesTriggered FROM CronTrigger]; // // [/code] CronTrigger "Contains schedule information for a scheduled job". Get the Id of the job you want to abort and execute this line on an anonymous window. [code lang="html"] // This line will abort the first entry on the crontList. // You need to make sure you have the…
Read More
From Picklist to SelectOption

From Picklist to SelectOption

Center Blog
From Picklist to SelectOption There are occasions in which you want to build an user interface that will not save records and it just interacts with the user input data. Something like a search engine or a currency converter app. In some cases, it is better to use SelectionOption than Picklist in your app. We can easily do this by using the Schema system class. As we know the Schema class "Contains methods for obtaining schema describe information". In this class, we can see how to pass all the values from a picklist to a List of SelectionOption. [code lang="php"] /********************************************************************** * * From Picklist to SelectionOption * ************************************************************************/ public without sharing class ConverterSupportClass { public List<SelectOption> CurrencyOptionsOne {get;set;} public List<SelectOption> CurrencyOptionsTwo {get;set;} static void ourMethod(){ // Getting all values…
Read More