Monday, 30 October 2017
Express yourself from Dreamoji
Dreamoji is the best way to express yourself with your favorite Salesforce characters.
• Dreamoji lets you choose from Astro, Appy, Einstein, Cloudy, Codey, and more!
• Heading to Dreamforce this year? Share Your Location via iMessage and meet up with colleagues
• Use Dreamoji in Hangouts, emails, and more!
• Add calendar reminders to register for our upcoming events, like Dreamforce '18
You can download it from playstore
https://play.google.com/store/apps/details?id=com.salesforce.dreamoji
Join Dreamforce live from Anywhere
Yes, its true that we can join Dreamforce live from anywhere.
Participate in #DF17 with the millions of Trailblazers online from all over the world on Salesforce Live! Even if you can't join us for Dreamforce in person, you'll have the opportunity to learn, connect and experience the event virtually.
Salesforce LIVE is a free broadcast experience featuring keynotes, studio shows, and surprise interviews with special guests as they happen in real-time from 8 different locations, over the 4 days of Dreamforce. Get included in all of the behind the scenes action, innovation, and learning by registering here for the Dreamforce Live Broadcast Experience.
Salesforce LIVE is a free broadcast experience featuring keynotes, studio shows, and surprise interviews with special guests as they happen in real-time from 8 different locations, over the 4 days of Dreamforce. Get included in all of the behind the scenes action, innovation, and learning by registering here for the Dreamforce Live Broadcast Experience.
You can check highlights for each day from here.
https://www.salesforce.com/blog/2017/10/dreamforce-schedule-salesforce-live.html
Register to Watch Live: http://bit.ly/DFLive17
Follow Salesforce Live on Twitter for updates throughout the week
Monday, 23 October 2017
Schedule Batch Job
Scheduler Class
-----------------------
global class AccountBatchScheduler implements Schedulable {
// Execute at regular intervals
global void execute(SchedulableContext ctx){
RunQuery batch = new RunQuery();
Database.executebatch(batch, 200);
}
}
We can schedule job from developer console.
System.schedule('AccountBatchScheduler', '0 0 * * * ?', new AccountBatchScheduler());
-----------------------
global class AccountBatchScheduler implements Schedulable {
// Execute at regular intervals
global void execute(SchedulableContext ctx){
RunQuery batch = new RunQuery();
Database.executebatch(batch, 200);
}
}
We can schedule job from developer console.
System.schedule('AccountBatchScheduler', '0 0 * * * ?', new AccountBatchScheduler());
Aggregate queries in Batch Apex
Recently, I came across one requirement, in which i need to use aggregate queries in batch apex .My requirement was to get maximum annual revenue of different account types.
I received below error message.
"Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch". I spent good time to find its solution.
To fix this error what we should do.
1. Create an Apex class implements Iterator<AggregateResult>.
2. Create an Apex class implements Iterable<AggregateResult>.
3. Implementing to Database.Batchable<AggregateResult>, and Using Iterable at start execution in Batch Apex.
Iterable Class
global class AggregateResultIterable implements Iterable<AggregateResult> {private String query;
global AggregateResultIterable(String soql){
query = soql;
}
global Iterator<AggregateResult> Iterator(){
return new AggregateResultIterator(query);
}
}
Iterator Class
global class AggregateResultIterator implements Iterator<AggregateResult> {AggregateResult [] results {get;set;}
// tracks which result item is returned
Integer index {get; set;}
global AggregateResultIterator(String query) {
index = 0;
results = Database.query(query);
}
global boolean hasNext(){
return results != null && !results.isEmpty() && index < results.size();
}
global AggregateResult next(){
return results[index++];
}
}
Batch Class
global class RunQuery implements Database.Batchable<AggregateResult> {// The batch job starts
global Iterable<AggregateResult> start(Database.BatchableContext bc){
String query = 'select name, type, max(AnnualRevenue) revenue from account where annualRevenue!= null group by name, type order by max(AnnualRevenue) desc';
return new AggregateResultIterable(query);
}
// The batch job executes and operates on one batch of records
global void execute(Database.BatchableContext bc, List<sObject> scope){
list <Account_Revenue__c> AR=new list<Account_Revenue__c>();
for(sObject sObj : scope) {
Account_Revenue__c c=new Account_Revenue__c();
AggregateResult a = (AggregateResult)sObj;
c.Name__c=string.valueof(a.get('name'));
c.Annual_Revenue__c=integer.valueof(a.get('revenue'));
c.Type__c=string.valueof(a.get('Type'));
AR.add(c);
}
database.insert(ar,false);
}
// The batch job finishes
global void finish(Database.BatchableContext bc){ }
}
We can schedule job using steps mentioned in this post.
Subscribe to:
Posts (Atom)