• gran
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
Hi

I wanna pass the value of a Campaign ID from a VF Page controller to an Apex Batch Class.

Here is my VF Controller's function:

public with sharing class SendCECertificate {
     public Campaign CAMP { get; set; }
     public Campaign CAMPID { get; set; }
    
     // Class Constructor
      public SendCECertificate(ApexPages.StandardController controller){
         CAMP =  (Campaign)controller.getRecord();              CAID = (Id)CAMP.Id; 
         CAMPID = (Id)CAMP.Id;     // this works fine
      }

      // This function is called from a commandLink  on a VF page
      public void sendEmail(){      
        // Invoke Batchclass from here....
        Database.executeBatch(new SendEmailBatchable(null), 10);
        // Keeping size to 10 to be under emailing governor limits... but how do we pass the CAMPID here? Can this function be overloaded?
    }


And then in the Apex Batch class, I wanna fetch the CAMPID

Here is the batchable class....

global class SendEmailBatchable implements Database.Batchable<SObject>, Database.Stateful {
private String query;
    private Id jobId;   
   
    global SendEmailBatchable(String query) {       
        this.query = query;
        if (this.query == null) {           
          this.query = 'SELECT Attended_CE_Training__c, CE_Credit_Certificate_Sent__c, CE_Credit_Certificate_Sent_Date__c, CampaignId, Id,ContactId, Event_Campaign_Comments__c, Primary_Language__c, RecordTypeId, RecordType.Name, Status, Contact.FirstName, Contact.Email FROM CampaignMember where CampaignId=\'701c0000000CHHz\' ' ;    // NOTE: I wanna replace this hardcoded ID with CAMPID which has to be sent from the VF controller
        }
    }
   
     global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext bc, List<SObject> batch) {    
      sendMail((List<CampaignMember>) batch );
      // Logic to fire email in batches of 10 as follows.....
     
    }
   
     public static void sendMail(List<CampaignMember> batch){
     
     }
    
     global void finish(Database.BatchableContext bc) {
         // Send a a confirmation email to the User who invoked the email blast
         ////// Database.executeBatch(new EAppBatchable(null), 2000);
    }
   
}

Any suggestions, what is the best way to do this?

Thanks
VK
  • May 30, 2014
  • Like
  • 0
Got a piece of code wherein I'm trying to fetch the key value from the map. 

trigger SetContactOwnerAndASD on Contact (before insert) {
Map mapConIdAccId = new Map();
for(Contact c:trigger.new){
mapConIdAccId.put(c.Id,c.AccountId);
}
List consList = new List();
System.Debug('Size='+mapConIdAccId.keySet().size());
for(Id i:mapConIdAccId.keySet()){
  Contact co = new Contact();
  co.Id = i;
  System.Debug('co.Id='+i); // this one is showing me null, but I'm trying to display the key
  co.AccountId = mapConIdAccId.get(i);
  System.Debug('co.AccountId='+co.AccountId);
  consList.add(co);
}

//update consList ;
}

I want to get the value of the key in the map but I'm getting a null for the variable "i". The second one i.e. mapConIdAccId.get(i) works fine and this one brings the value. How do I display the key itself, not the value?

Thanks
V

Thanks
  • March 03, 2014
  • Like
  • 0

Hello

 

I installed Eclipse Force.com IDE today. Installation went good. This is the one for Windows 64-bit.

 

While trying to connect to my Sandbox (Test), I entered the following:

 

Project Name = <Here I specified a project name>

Username = <Entering the username that I use to login to test.salesforce.com>

Password = <the password> + <Security Token>

Environment = Sandbox

 

When I click on login, I get the following message:

Unable to fetch the organization details for '<Username as I entered above>'

 

What could I be doing wrong?

 

Thanks

gran

 

 

 

 

  • July 05, 2013
  • Like
  • 0
Hi,

When we make future calls, a job gets enqueued in asyncapexjob record. Is there any way to get job id of future call which has been currently made?
For example, I have a button on case record, when I click that button, a future method runs and calls other web service. Now, multipe people can click on the button at the same time/or almost near by time so I want to display the status of their job.

Is it possible at all?

Thanks.
Hi

I wanna pass the value of a Campaign ID from a VF Page controller to an Apex Batch Class.

Here is my VF Controller's function:

public with sharing class SendCECertificate {
     public Campaign CAMP { get; set; }
     public Campaign CAMPID { get; set; }
    
     // Class Constructor
      public SendCECertificate(ApexPages.StandardController controller){
         CAMP =  (Campaign)controller.getRecord();              CAID = (Id)CAMP.Id; 
         CAMPID = (Id)CAMP.Id;     // this works fine
      }

      // This function is called from a commandLink  on a VF page
      public void sendEmail(){      
        // Invoke Batchclass from here....
        Database.executeBatch(new SendEmailBatchable(null), 10);
        // Keeping size to 10 to be under emailing governor limits... but how do we pass the CAMPID here? Can this function be overloaded?
    }


And then in the Apex Batch class, I wanna fetch the CAMPID

Here is the batchable class....

global class SendEmailBatchable implements Database.Batchable<SObject>, Database.Stateful {
private String query;
    private Id jobId;   
   
    global SendEmailBatchable(String query) {       
        this.query = query;
        if (this.query == null) {           
          this.query = 'SELECT Attended_CE_Training__c, CE_Credit_Certificate_Sent__c, CE_Credit_Certificate_Sent_Date__c, CampaignId, Id,ContactId, Event_Campaign_Comments__c, Primary_Language__c, RecordTypeId, RecordType.Name, Status, Contact.FirstName, Contact.Email FROM CampaignMember where CampaignId=\'701c0000000CHHz\' ' ;    // NOTE: I wanna replace this hardcoded ID with CAMPID which has to be sent from the VF controller
        }
    }
   
     global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext bc, List<SObject> batch) {    
      sendMail((List<CampaignMember>) batch );
      // Logic to fire email in batches of 10 as follows.....
     
    }
   
     public static void sendMail(List<CampaignMember> batch){
     
     }
    
     global void finish(Database.BatchableContext bc) {
         // Send a a confirmation email to the User who invoked the email blast
         ////// Database.executeBatch(new EAppBatchable(null), 2000);
    }
   
}

Any suggestions, what is the best way to do this?

Thanks
VK
  • May 30, 2014
  • Like
  • 0

Hello

 

I installed Eclipse Force.com IDE today. Installation went good. This is the one for Windows 64-bit.

 

While trying to connect to my Sandbox (Test), I entered the following:

 

Project Name = <Here I specified a project name>

Username = <Entering the username that I use to login to test.salesforce.com>

Password = <the password> + <Security Token>

Environment = Sandbox

 

When I click on login, I get the following message:

Unable to fetch the organization details for '<Username as I entered above>'

 

What could I be doing wrong?

 

Thanks

gran

 

 

 

 

  • July 05, 2013
  • Like
  • 0

Hi,

Am unable to refresh any of the resources in the IDE from the server.

When am trying to refresh a page from the web, getting an Exception saying:

 

 

Unable to refresh resource 'MileaeExension.cls':
com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Unable to refresh resource 'MileaeExension.cls':


com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor

 

Please assist to rectify the issue. 

 

Thanks in advance,

VNath