• kanchi chandra mohan
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
i have vf page. 2d carousel was working only on <img> only. so i need Report charts instead of img tag
there is relationship between two objects.. parent and child.. parent having text field..chila have picklist field..if i update the parent field in parent as 'xxx' then it automatically display in child object picklist value as 'completed' .how can u achieve? relationship:master
  • December 05, 2014
  • Like
  • 0
i need to process contacts and their trainings and need to do this via batch as its around 75k records when joined. this is a one time job so i was hoping to write a class and then call it via execute anonymous. in my testing on very small numbers in my sandbox, i only get the batch execution to run once, while im deliberately trying to get it to run more than once. for example, i have 25 records so i want to run in batches of 10 to run 3 times; 10, 10, 5. but it looks like it only runs once for 10 records. secondly, it looks like the query does not re-run on subsequent runs (if i even am running more than once). Meaning if the first 8 records are for one contact and the next 8 are for another, but i only run in a size of 10, the second contacts records will be split ovef the first run and second run. Im using a flag to set whether these records are 'counted' towards a certification but im guessing the records would be split rather than requery for records not flagged as being used. heres some code for partial example of how the basics are set up
 
global class Batch_TrainingLegacyBackfill implements Database.Batchable<sObject> {
	
	List<training_c> ContactTrainings;
	String query;
	
	global Batch_TrainingLegacyBackfill() {
		query = 'SELECT Id, Name, Certification__c, Chapter_Name__c, Course_Name__c, Complete_Date__c, Legacy_Processed__c, '  
					+ 'Contact__r.Id, Contact__r.Name, Contact__r.Email, Contact__r.Last_Training_Date__c , Contact__r.Number_of_Trainings__c ' 
					+ 'FROM training__c WHERE Legacy_Processed__c = null ORDER BY Contact__r.Id, Course_Name__c, Chapter_Name__c LIMIT 10';
	}
	
	global Database.QueryLocator start(Database.BatchableContext BC) {
		system.debug('query = ' + query);
		return Database.getQueryLocator(query);
	}

   	global void execute(Database.BatchableContext BC, List<sObject> scope) {
   		system.debug('scope = ' + scope);
		// grab records
		ContactTrainings = (List<training__c>)scope;

		for(training__c c : ContactTrainings){ // more logic than id care to admit...}

	}
	
	global void finish(Database.BatchableContext BC) {
		// email to verify
		
	}
}
//from execute anonymous

Batch_TrainingLegacyBackfill bbf = new Batch_TrainingLegacyBackfill();
Database.ExecuteBatch(bbf);


to recap:
1) if i have 5 contacts with a total of 25 records and have my limit set to 10, should this run 3 times?
2) can i get this ti run multiple times from execute anonymous
3) if it runs multilpe times, would it re-query everytime to bring back overlapping contact trainings?
Hi All,

I am having 2 objects called ObjA__c and ObjB__c and fileds are same in both objects viz. name phone__c,email__c. So my requirement is whenever i inserted records on ObjA__C automatically same record should insert into ObjB__C for that code is

trigger AutoUpdate on MainDemo__c (Before insert, Before Update) {

    List<Demo__C> dl = new List<Demo__C>();
    List<Demo__C> dlu1 = new List<Demo__C>();
    if(Trigger.isInsert){
    for(MainDemo__C md:Trigger.new){
    
        Demo__c d = new Demo__c();
        d.name=md.name; 
        d.email__c=md.email__c;
        d.phone__c=md.phone__c;
        dl.add(d);
    
    }
    insert dl;
    } 

Now whenever i update record in Obj__A same record should update in objB__C but problem here is updated record is reinserting in objB__C how can i achieve this and also same for "Delete"

Thanks,
A.Jagadeesh