• Warjie
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 6
    Replies
Hi folks!

I have a batch class that is called from another batch class. As of now, what the job does is doing some system debug to check the records to be processed. For some reason, I cannot see the debug. This prevents me from doing the DMLs (which is the real action in the job) since I'm not sure if it will really execute the DMLs given that a simple debug doesn't show up. I have set the debug to FINEST and I got the below. Can you please help me? Thanks!

Calling of batch
Datetime sysTime = System.now().addMinutes(2);
String chronExpression =  sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + '  ? ' + sysTime.year();      
DeleteAttachmentBatchClass batchjob = new DeleteAttachmentBatchClass();
System.schedule('Delete Attachment', chronExpression, batchjob );

Batch job
global class DeleteAttachmentBatchClass implements Database.Batchable<sObject>, schedulable, Database.Stateful{
    public String query;
    public List<Account> accList = new List<Account>();
    public List<Attachment> attachmentList = new List<Attachment>();
    public Set<Id> accSet = new Set<Id>();
    public Set<String> fileNameSet = new Set<String>();

    global DeleteAttachmentBatchClass(){
        query = 'SELECT Id, Customer_Number__c, (Select License_Number__c FROM Licenses__r) FROM Account WHERE SentEmailToLicenseContact__c = TRUE AND Attachment_Age__c != null AND Licence_Email__c != null AND Local_Language__c != null';
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Account> scope){
        system.debug('**Scope: ' + scope.size() + ' - ' + scope);
        for(Account a: scope){
            a.SentEmailToLicenseContact__c = False;
            a.Attachment_Age__c = null;
            accSet.add(a.Id);
            for(Licenses__c l: a.Licenses__r){
                fileNameSet.add(l.License_Number__c + ' - ' + a.Customer_Number__c + ' - ' + System.Today().year() + '.pdf');
            }           
        }
        
        attachmentList = [SELECT Id, Name, ParentId FROM Attachment WHERE ParentID IN: accSet AND name IN: fileNameSet];
        system.debug('**attachmentList: ' + attachmentList.size() + ' - ' + attachmentList);
    }
    
    global void finish(Database.BatchableContext BC){
    }
    
    global void execute(SchedulableContext SC){
    }
}

Debug
36.0 APEX_CODE,FINEST;APEX_PROFILING,FINEST;CALLOUT,INFO;DB,FINEST;SYSTEM,FINEST;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
13:34:48.0 (97413)|EXECUTION_STARTED
13:34:48.0 (151374)|CODE_UNIT_STARTED|[EXTERNAL]|01p7E00000096wA|Delete Attachment
13:34:48.0 (5874005)|HEAP_ALLOCATE|[72]|Bytes:3
13:34:48.0 (5961992)|HEAP_ALLOCATE|[77]|Bytes:152
13:34:48.0 (5986568)|HEAP_ALLOCATE|[342]|Bytes:408
13:34:48.0 (6007947)|HEAP_ALLOCATE|[355]|Bytes:408
13:34:48.0 (6028580)|HEAP_ALLOCATE|[467]|Bytes:48
13:34:48.0 (6074907)|HEAP_ALLOCATE|[139]|Bytes:6
13:34:48.0 (15380024)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:3
13:34:48.0 (15406931)|SYSTEM_METHOD_ENTRY|[1]|SchedulableContextImpl.SchedulableContextImpl()
13:34:48.0 (15412854)|STATEMENT_EXECUTE|[1]
13:34:48.0 (15432851)|SYSTEM_METHOD_EXIT|[1]|SchedulableContextImpl
13:34:48.0 (15441773)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
13:34:48.0 (15447416)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:34:48.0 (15463447)|VARIABLE_SCOPE_BEGIN|[4]|this|System.SchedulableContextImpl|true|false
13:34:48.0 (15544606)|VARIABLE_ASSIGNMENT|[4]|this|{}|0x77b01072
13:34:48.0 (15552147)|VARIABLE_SCOPE_BEGIN|[4]|triggerId|Id|false|false
13:34:48.0 (15642403)|VARIABLE_ASSIGNMENT|[4]|triggerId|"08e7E000000hGNrQAM"
13:34:48.0 (15840917)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:91
13:34:48.0 (15848470)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:13
13:34:48.0 (15851167)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
13:34:48.0 (15865363)|METHOD_ENTRY|[1]|01p7E00000096wA|DeleteAttachmentBatchClass.DeleteAttachmentBatchClass()
13:34:48.0 (15869731)|STATEMENT_EXECUTE|[1]
13:34:48.0 (15875934)|STATEMENT_EXECUTE|[1]
13:34:48.0 (15884876)|METHOD_EXIT|[1]|DeleteAttachmentBatchClass
13:34:48.0 (15890596)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:24
13:34:48.0 (15893265)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
13:34:48.0 (15904090)|VARIABLE_SCOPE_BEGIN|[34]|this|DeleteAttachmentBatchClass|true|false
13:34:48.0 (15949827)|VARIABLE_ASSIGNMENT|[34]|this|{"accList":"0x20f2d544","accSet":"0x79d48f07","attachmentList":"0xe1023cf","fileNameSet":"0x2c1652fb","query":"SELECT Id, Customer_ (198 more) ..."}|0x1a78eac8
13:34:48.0 (15964437)|VARIABLE_SCOPE_BEGIN|[34]|SC|System.SchedulableContext|true|false
13:34:48.0 (16039084)|VARIABLE_ASSIGNMENT|[34]|SC|{"triggerId":"08e7E000000hGNrQAM"}|0x77b01072
13:34:48.0 (16054954)|STATEMENT_EXECUTE|[34]
13:34:48.16 (16073571)|CUMULATIVE_LIMIT_USAGE
13:34:48.16 (16073571)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

13:34:48.16 (16073571)|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
13:34:48.16 (16073571)|STATIC_VARIABLE_LIST|
  char[]:DigitTens:0
  long:serialVersionUID:0
  String:_sfdcAdditionalCodeLocations:0
  double:MAX_VALUE:0
  long:serialVersionUID:0
  double:MIN_VALUE:0
  int:SIZE:0
  double:NEGATIVE_INFINITY:0
  int:MAX_VALUE:0
  char[]:digits:0
  double:NaN:0
  String:_sfdcAdditionalCodeLocations:0
  String:_sfdcAdditionalCodeLocations:0
  int:MIN_VALUE:0
  char[]:DigitOnes:0
  int:BYTES:0
  String:__sfdcParameterizedTypes:0
  int:MIN_EXPONENT:0
  String:_sfdcSuppressedCodeLocations:0
  int[]:sizeTable:0
  int:MAX_EXPONENT:0
  int:SIZE:0
  double:POSITIVE_INFINITY:0
  double:MIN_NORMAL:0
  int:BYTES:0

13:34:48.16 (16073571)|CUMULATIVE_LIMIT_USAGE_END

13:34:48.0 (16339043)|CODE_UNIT_FINISHED|Delete Attachment
13:34:48.0 (17446531)|EXECUTION_FINISHED
13:34:48.29 (29359753)|CUMULATIVE_PROFILING_BEGIN
13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for SOQL operations
13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for SOSL operations
13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for DML operations
13:34:48.29 (29359753)|CUMULATIVE_PROFILING|method invocations|
External entry point: global void execute(System.SchedulableContext): executed 1 time in 0 ms

13:34:48.29 (29359753)|CUMULATIVE_PROFILING_END


 
  • March 30, 2016
  • Like
  • 0
Hi, I have read the order of execution from Salesforce (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm) and it seems like contradicting to what I'm getting with my test.

Please see below timeline of events/results of my test:
  1. Save button (saveAdjustments method) in a VF page is clicked.
  2. Inside the code, it sets the Approval Status of Transaction Adjustment (TA) to "Pending".
  3. It will insert a new TA record.
  4. Workflow rule will run: Update Case Status on Transaction Adjustment
  5. Workflow will update the Approval Status of TA to "Awaiting Approval".
  6. After the TA has been created, I noticed that the TA's Approval Status is now back to "Pending" even though the rule was successfully met.
Here's the debug and it seems that the rule was called first before the save method was invoked.

User-added image
This is a portion of the code where it sets the status to "Pending" as a default value:
public PageReference saveAdjustments(){
        
        // Set up list for insertion
        Decimal appLimit = getApprovalAmountLimit();
        Decimal secLimit = getSecondApprovalAmountLimit();
        list<Transaction_Adjustment__c> taToInsert = new list<Transaction_Adjustment__c>();
        for (AdjustmentWrapper item : adjustmentList){
            item.ta.Approval_Status__c = pendingStatus; //pendingStatus = 'Pending'
Notes:
  1. I cannot simply comment out the assignment of Approval Status in the code as it is being used in the creation of another record from a different object. Doing so caused me to experience a null reference error.
  2. I cannot also change the status to "Awaiting Approval" in the code as I don't know the full impact. I;m not the one who created this.
MAIN QUESTION:
- Is there a way to make the Approval Status to "Awaiting Approval" via workflow with at least minimal change(s)?

Appreciate your response everyone! Thanks!
  • January 13, 2016
  • Like
  • 0
Hi awesome people,

Our client has a mulesoft job using Bulk API. It queries first a total of 200,000 records and then hard deletes it. However starting Oct. 17, the maximum number of records being queried by the job is now only 2,000 though in MuleSoft it is still 200K. I'm suspecting it has something to do with the Winter '16 update last oct. 17 in AP1 instances. However I can't find any significant documentation supporting this theory as of now.

Can you shed some light here? Thanks!
  • October 22, 2015
  • Like
  • 1
Hi, we have a mulesoft job that do 2 things:
1.) Query & extract records older than 27 months. Normal expected record count is 1M above.
2.) Hard delete the extract records

Before, the query only takes 20 minutes to complete. However we noticed since Saturday and Sunday (June 13, 14, 2015) that the query alone takes too much time (2 hours have passed and only 6% was completed) so we have to abort it.

Can anyone give me thoughts on what could be the possible cause of this issue?

Thanks!
Hi All, I've created a batch class implementing Iterable. A class calls the batch class passing the list of records to be inserted (in the batch). I was able to save this code without issue but I'm not sure if this will work. Can you give me your insights on this please?

Class that calls the batch:
//these lists are filled inside the class and are to be inserted inside the batch to prevent DML 10001
batchWOSharing bc = new batchWOSharing(jobShareList, 'Jobs__Share');
ID batchProcessId = Database.executeBatch(bc, 200);
batchWOSharing bc2 = new batchWOSharing(opportunityShareList, 'OpportunityShare');
ID batchProcessId2 = Database.executeBatch(bc2, 200);    
batchWOSharing bc3 = new batchWOSharing(invoiceShareList, 'Invoice__Share');
ID batchProcessId3 = Database.executeBatch(bc3, 200);
batchWOSharing bc4 = new batchWOSharing(accShare, 'AccountShare');
ID batchProcessId4 = Database.executeBatch(bc4, 200);

Batch class called:
global class batchWOSharing implements Database.Batchable<sObject>{
    public List<sObject> objectList = new List<sObject>();
    String obj;
	
    global batchWOSharing(List<sObject> objectList2, String obj2){
		this.obj = obj2;        
        this.objectList = objectList2;
    }
	
	global Iterable<sObject> start(Database.batchableContext BC){
		return new List<sObject>();
	}	
    
    global void execute(Database.BatchableContext BC, List<sObject> scope){   
		List<sObject> objectToUpdate = new List<sObject>();

        for(sObject s: scope){
            objectToUpdate.add(s);
        }
		if(obj == 'Jobs__Share'){
			List<Jobs__Share> jobShareList = (List<Jobs__Share>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'OpportunityShare'){
			List<OpportunityShare> opptyShareList = (List<OpportunityShare>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'Invoice__Share'){
			List<Invoice__Share> invShareList = (List<Invoice__Share>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'AccountShare'){
			List<AccountShare> accShareList = (List<AccountShare>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
    }
    
    global void finish(Database.BatchableContext BC){
    }
}

 
  • February 03, 2015
  • Like
  • 0
Hi, I come across a need to fill this requirement.

1. Create a custom Link that will redirect users to a custom report - DONE
2. Apex code to pass the parameter for the report to the custom link

Can anybody give me an idea how to do step #2?

Thanks :)
  • November 28, 2014
  • Like
  • 0

hi, i have a vf page consists of 2 pages. But these 2 pages only use 1 controller. Here's what i need to do, if you select a value from the dropdown in page 1, the other dropdown from page2 will display only the approriate values depending on the value you chose in dropdown 1. here's part of the code:

 

    public List<SelectOption> getCampusLocations() {
    	
        List<SelectOption> options = new List<SelectOption>();
        //this.vfhFormRecord.VET_Qualification__c
        
        Set<String> locationNames = new Set<String>();
        /*
        for(Locations__c loc: [Select Id, Name from Locations__c WHERE RecordType.DeveloperName = 'Training_Delivery_Location' Order By Name ] ) {
            options.add(new SelectOption(loc.Id, loc.Name)); 
        }*/
        
        //filter the parent location names from qualification locations related to the qualification selected
        Set<Id> qualificationIds = new Set<Id>();
        Set<String> commonNameCheck = new Set<String>();
        
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        
        
        for(Qualification_Location__c qLoc: [Select Location__r.Name from Qualification_Location__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(qLoc.Location__r.Name)) {
                commonNameCheck.add(qLoc.Location__r.Name);
                locationNames.add(qLoc.Location__r.Name);
            }
        }
            
        //filter the locations using the location names and vet provider
        if(locationNames.size()>0) {
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name = 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name));
            }
        
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name IN: locationNames AND Name != 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name)); 
            }

        }
        
        return options; 
    }

 

    public List<SelectOption> getDeliveryModes() {
        List<SelectOption> options = new List<SelectOption>();
        Set<Id> qualificationIds = new Set<Id>();
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        Set<String> commonNameCheck = new Set<String>();
        for(Qualification_Delivery_Mode__c dqm: [Select Delivery_Mode__c, Delivery_Mode_Common_Name__c from Qualification_Delivery_Mode__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(dqm.Delivery_Mode_Common_Name__c)) {
                commonNameCheck.add(dqm.Delivery_Mode_Common_Name__c);
                options.add(new SelectOption(dqm.Delivery_Mode__c, dqm.Delivery_Mode_Common_Name__c)); 
            }
        }

        return options; 
    }

 here's the vf page:

 

            <table width="100%" style="width:100%;">
                <tr>
                    <td colspan="4" class="tableHeader">
                        <apex:outputText value="Qualification Details"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <apex:outputLabel value="I wish to apply to study in the following mode* :" for="DeliveryModeFrm1"/>
                    </td>
                    <td>
                        <apex:selectList size="1" value="{!vfhFormRecord.Delivery_Mode_Type__c}" id="DeliveryModeFrm1">
                            <apex:selectOptions value="{!DeliveryModes}"/>
                        </apex:selectList>
                    </td>
                    <td colspan="2" style="width:50%">
                        &nbsp;
                    </td>
                </tr>
            </table>

 so what i do for get and set of the apexlist is this: (which is i know totally wrong)

 

    //DeliveryModeFrm1
 	public String[] getVfhFormRecord.Delivery_Mode_Type__c(){
        return this.selectedDelivery;
    }
    
    public void setVfhFormRecord.Delivery_Mode_Type__c(String[] selectedDelivery){
        this.selectedDelivery = selectedDelivery;
    }

 can anyone give me an idea how can i get the selected value from dropdown 1?

 

so i want to add a filter in getCampusLocations once i get the value chosen in the dropdown1

 

thanks very much

  • September 03, 2013
  • Like
  • 0

hi, i have a vf page consists of 2 pages. But these 2 pages only use 1 controller. Here's what i need to do, if you select a value from the dropdown in page 1, the other dropdown from page2 will display only the approriate values depending on the value you chose in dropdown 1. here's part of the code:

 

    public List<SelectOption> getCampusLocations() {
    	
        List<SelectOption> options = new List<SelectOption>();
        //this.vfhFormRecord.VET_Qualification__c
        
        Set<String> locationNames = new Set<String>();
        /*
        for(Locations__c loc: [Select Id, Name from Locations__c WHERE RecordType.DeveloperName = 'Training_Delivery_Location' Order By Name ] ) {
            options.add(new SelectOption(loc.Id, loc.Name)); 
        }*/
        
        //filter the parent location names from qualification locations related to the qualification selected
        Set<Id> qualificationIds = new Set<Id>();
        Set<String> commonNameCheck = new Set<String>();
        
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        
        
        for(Qualification_Location__c qLoc: [Select Location__r.Name from Qualification_Location__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(qLoc.Location__r.Name)) {
                commonNameCheck.add(qLoc.Location__r.Name);
                locationNames.add(qLoc.Location__r.Name);
            }
        }
            
        //filter the locations using the location names and vet provider
        if(locationNames.size()>0) {
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name = 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name));
            }
        
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name IN: locationNames AND Name != 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name)); 
            }

        }
        
        return options; 
    }

 

    public List<SelectOption> getDeliveryModes() {
        List<SelectOption> options = new List<SelectOption>();
        Set<Id> qualificationIds = new Set<Id>();
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        Set<String> commonNameCheck = new Set<String>();
        for(Qualification_Delivery_Mode__c dqm: [Select Delivery_Mode__c, Delivery_Mode_Common_Name__c from Qualification_Delivery_Mode__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(dqm.Delivery_Mode_Common_Name__c)) {
                commonNameCheck.add(dqm.Delivery_Mode_Common_Name__c);
                options.add(new SelectOption(dqm.Delivery_Mode__c, dqm.Delivery_Mode_Common_Name__c)); 
            }
        }

        return options; 
    }

 here's the vf page:

 

            <table width="100%" style="width:100%;">
                <tr>
                    <td colspan="4" class="tableHeader">
                        <apex:outputText value="Qualification Details"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <apex:outputLabel value="I wish to apply to study in the following mode* :" for="DeliveryModeFrm1"/>
                    </td>
                    <td>
                        <apex:selectList size="1" value="{!vfhFormRecord.Delivery_Mode_Type__c}" id="DeliveryModeFrm1">
                            <apex:selectOptions value="{!DeliveryModes}"/>
                        </apex:selectList>
                    </td>
                    <td colspan="2" style="width:50%">
                        &nbsp;
                    </td>
                </tr>
            </table>

 so what i do for get and set of the apexlist is this: (which is i know totally wrong)

 

    //DeliveryModeFrm1
 	public String[] getVfhFormRecord.Delivery_Mode_Type__c(){
        return this.selectedDelivery;
    }
    
    public void setVfhFormRecord.Delivery_Mode_Type__c(String[] selectedDelivery){
        this.selectedDelivery = selectedDelivery;
    }

 can anyone give me an idea how can i get the selected value from dropdown 1?

 

thanks very much

  • September 03, 2013
  • Like
  • 0

hi, I have a VF page that shows all the data per month. When you click the button, the page will load and will display no data (rarely). i think its some SF or internet issue. Here's the code

 

 

public with sharing class ReportPartnerTrialistController {
public List<Analytic_Report__c> PartnerReports {get; set;}
public boolean showSendEmailButton {get; set;}
public boolean showRecalculateButton {get; set;}
public boolean ArReportEmailSent {get; set;}
public integer previousMonths {get; set;}
public String monthReport {get; set;}
public String yearReport {get; set;}
public date firstDayMonthReport {get; set;}

public ReportPartnerTrialistController() {
  // set month with previousMonths number
  if (previousMonths == null) previousMonths = 0;
  // recalculate button to true
  // showRecalculateButton = true;
}

public List<Analytic_Report__c> getReports() {
 
  firstDayMonthReport = date.today().addMonths(-(1 + previousMonths)).toStartOfMonth();
  // add test flag as no old data can be created from test
  if(Test.isRunningTest() == true){
   firstDayMonthReport = date.today().toStartOfMonth();
  }
  String monthAR = String.Valueof(firstDayMonthReport.month());
     yearReport = String.Valueof(firstDayMonthReport.year());
    
     if (monthAR == '1') monthAR = 'January';
     if (monthAR == '2') monthAR = 'February';
     if (monthAR == '3') monthAR = 'March';
     if (monthAR == '4') monthAR = 'April';
     if (monthAR == '5') monthAR = 'May';
     if (monthAR == '6') monthAR = 'June';
     if (monthAR == '7') monthAR = 'July';
     if (monthAR == '8') monthAR = 'August';
     if (monthAR == '9') monthAR = 'September';
     if (monthAR == '10') monthAR = 'October';
     if (monthAR == '11') monthAR = 'November';
     if (monthAR == '12') monthAR = 'December';
     monthReport = monthAR;
    
  // set display for send email button
  List<Report_Email__c> ReportEmails = new List<Report_Email__c>([Select Id, Name, Analytic_Report__c, Contact__c, Email_status__c, type__c from Report_Email__c where Email_status__c = 'Waiting' and Analytic_Report__r.Month__c = :monthReport and Analytic_Report__r.year__c = :yearReport ]);
       if(ReportEmails.size() > 0){
        showSendEmailButton = true;
        showRecalculateButton = true;
       }else{
        showSendEmailButton = false;
        showRecalculateButton = false;
       }

  PartnerReports = new List<Analytic_Report__c>([Select Referring_Partner__c,Referring_Partner__r.Name, Partner_City__c, Month__c, Year__c, Type__c, Patients_who_completed_trial__c,Patients_who_have_not_purchased_products__c,Patients_who_purchased_products__c,Patients_who_started_trial__c,Emails__c, Financial_situation_constraints__c,Non_Compliant__c,Not_an_immediate_priority__c,Other__c,Average_Trial_Time__c, Number_of_Patients_not_contactable__c, Purchased_from_partner__c, Purchased_from_an_other_partner__c,Purchased_from_internet__c, Patients_who_discontinued__c, Purchased_from_government__c, Purchased_from_second_hand__c   
   from Analytic_Report__c
   where  Type__c = 'Partner Trialist Report' and Month__c =: monthReport and Year__c = :yearReport
   order by Referring_Partner__r.Name asc ]);
  return PartnerReports;
}

public PageReference sendEmails(){
       List<Report_Email__c> ReportEmails = new List<Report_Email__c>([Select Id, Name, Analytic_Report__c, Contact__c, Email_status__c, type__c from Report_Email__c where Email_status__c = 'Waiting' and Analytic_Report__r.Month__c = :monthReport and Analytic_Report__r.year__c = :yearReport ]);
       List<Note> emailSentNotes = new List<Note>();
       for (Report_Email__c re :ReportEmails ){
        // set the status for the workflow rule to send email using template - the status will be change to sent by the workflow rule
        re.Email_status__c = 'To be sent';
        Note tempNote = new Note();
        tempNote.Title = 'Partner Trialist HTML Email sent - ' + monthReport + ' ' + yearReport;
        tempNote.ParentId = re.Contact__c;
        tempNote.Body = 'Trialist Partner Report \n \n Sent from the Analytic Report record: ' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + re.Analytic_Report__c;
        emailSentNotes.add(tempNote);
       
       }
       // add notes to all contact who email was sent to
       insert emailSentNotes;
      
       update ReportEmails;
       PageReference newpage = new PageReference(System.currentPageReference().getURL());
     newpage.setRedirect(true);
     return newpage;
    }
   
    public PageReference movePreviousMonth(){
       previousMonths++;
     return null;
    }
   
    public PageReference lastMonth(){
       // set previousMonths to 0
       previousMonths = 0;
       return null;
    }
   

  • August 16, 2013
  • Like
  • 0
Hi awesome people,

Our client has a mulesoft job using Bulk API. It queries first a total of 200,000 records and then hard deletes it. However starting Oct. 17, the maximum number of records being queried by the job is now only 2,000 though in MuleSoft it is still 200K. I'm suspecting it has something to do with the Winter '16 update last oct. 17 in AP1 instances. However I can't find any significant documentation supporting this theory as of now.

Can you shed some light here? Thanks!
  • October 22, 2015
  • Like
  • 1
Hi awesome people,

Our client has a mulesoft job using Bulk API. It queries first a total of 200,000 records and then hard deletes it. However starting Oct. 17, the maximum number of records being queried by the job is now only 2,000 though in MuleSoft it is still 200K. I'm suspecting it has something to do with the Winter '16 update last oct. 17 in AP1 instances. However I can't find any significant documentation supporting this theory as of now.

Can you shed some light here? Thanks!
  • October 22, 2015
  • Like
  • 1
Hi All, I've created a batch class implementing Iterable. A class calls the batch class passing the list of records to be inserted (in the batch). I was able to save this code without issue but I'm not sure if this will work. Can you give me your insights on this please?

Class that calls the batch:
//these lists are filled inside the class and are to be inserted inside the batch to prevent DML 10001
batchWOSharing bc = new batchWOSharing(jobShareList, 'Jobs__Share');
ID batchProcessId = Database.executeBatch(bc, 200);
batchWOSharing bc2 = new batchWOSharing(opportunityShareList, 'OpportunityShare');
ID batchProcessId2 = Database.executeBatch(bc2, 200);    
batchWOSharing bc3 = new batchWOSharing(invoiceShareList, 'Invoice__Share');
ID batchProcessId3 = Database.executeBatch(bc3, 200);
batchWOSharing bc4 = new batchWOSharing(accShare, 'AccountShare');
ID batchProcessId4 = Database.executeBatch(bc4, 200);

Batch class called:
global class batchWOSharing implements Database.Batchable<sObject>{
    public List<sObject> objectList = new List<sObject>();
    String obj;
	
    global batchWOSharing(List<sObject> objectList2, String obj2){
		this.obj = obj2;        
        this.objectList = objectList2;
    }
	
	global Iterable<sObject> start(Database.batchableContext BC){
		return new List<sObject>();
	}	
    
    global void execute(Database.BatchableContext BC, List<sObject> scope){   
		List<sObject> objectToUpdate = new List<sObject>();

        for(sObject s: scope){
            objectToUpdate.add(s);
        }
		if(obj == 'Jobs__Share'){
			List<Jobs__Share> jobShareList = (List<Jobs__Share>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'OpportunityShare'){
			List<OpportunityShare> opptyShareList = (List<OpportunityShare>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'Invoice__Share'){
			List<Invoice__Share> invShareList = (List<Invoice__Share>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
		if(obj == 'AccountShare'){
			List<AccountShare> accShareList = (List<AccountShare>) objectToUpdate;
			Database.insert(objectToUpdate, false);
		}
    }
    
    global void finish(Database.BatchableContext BC){
    }
}

 
  • February 03, 2015
  • Like
  • 0
Hi, I come across a need to fill this requirement.

1. Create a custom Link that will redirect users to a custom report - DONE
2. Apex code to pass the parameter for the report to the custom link

Can anybody give me an idea how to do step #2?

Thanks :)
  • November 28, 2014
  • Like
  • 0

hi, i have a vf page consists of 2 pages. But these 2 pages only use 1 controller. Here's what i need to do, if you select a value from the dropdown in page 1, the other dropdown from page2 will display only the approriate values depending on the value you chose in dropdown 1. here's part of the code:

 

    public List<SelectOption> getCampusLocations() {
    	
        List<SelectOption> options = new List<SelectOption>();
        //this.vfhFormRecord.VET_Qualification__c
        
        Set<String> locationNames = new Set<String>();
        /*
        for(Locations__c loc: [Select Id, Name from Locations__c WHERE RecordType.DeveloperName = 'Training_Delivery_Location' Order By Name ] ) {
            options.add(new SelectOption(loc.Id, loc.Name)); 
        }*/
        
        //filter the parent location names from qualification locations related to the qualification selected
        Set<Id> qualificationIds = new Set<Id>();
        Set<String> commonNameCheck = new Set<String>();
        
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        
        
        for(Qualification_Location__c qLoc: [Select Location__r.Name from Qualification_Location__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(qLoc.Location__r.Name)) {
                commonNameCheck.add(qLoc.Location__r.Name);
                locationNames.add(qLoc.Location__r.Name);
            }
        }
            
        //filter the locations using the location names and vet provider
        if(locationNames.size()>0) {
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name = 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name));
            }
        
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name IN: locationNames AND Name != 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name)); 
            }

        }
        
        return options; 
    }

 

    public List<SelectOption> getDeliveryModes() {
        List<SelectOption> options = new List<SelectOption>();
        Set<Id> qualificationIds = new Set<Id>();
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        Set<String> commonNameCheck = new Set<String>();
        for(Qualification_Delivery_Mode__c dqm: [Select Delivery_Mode__c, Delivery_Mode_Common_Name__c from Qualification_Delivery_Mode__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(dqm.Delivery_Mode_Common_Name__c)) {
                commonNameCheck.add(dqm.Delivery_Mode_Common_Name__c);
                options.add(new SelectOption(dqm.Delivery_Mode__c, dqm.Delivery_Mode_Common_Name__c)); 
            }
        }

        return options; 
    }

 here's the vf page:

 

            <table width="100%" style="width:100%;">
                <tr>
                    <td colspan="4" class="tableHeader">
                        <apex:outputText value="Qualification Details"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <apex:outputLabel value="I wish to apply to study in the following mode* :" for="DeliveryModeFrm1"/>
                    </td>
                    <td>
                        <apex:selectList size="1" value="{!vfhFormRecord.Delivery_Mode_Type__c}" id="DeliveryModeFrm1">
                            <apex:selectOptions value="{!DeliveryModes}"/>
                        </apex:selectList>
                    </td>
                    <td colspan="2" style="width:50%">
                        &nbsp;
                    </td>
                </tr>
            </table>

 so what i do for get and set of the apexlist is this: (which is i know totally wrong)

 

    //DeliveryModeFrm1
 	public String[] getVfhFormRecord.Delivery_Mode_Type__c(){
        return this.selectedDelivery;
    }
    
    public void setVfhFormRecord.Delivery_Mode_Type__c(String[] selectedDelivery){
        this.selectedDelivery = selectedDelivery;
    }

 can anyone give me an idea how can i get the selected value from dropdown 1?

 

thanks very much

  • September 03, 2013
  • Like
  • 0

hi, I have a VF page that shows all the data per month. When you click the button, the page will load and will display no data (rarely). i think its some SF or internet issue. Here's the code

 

 

public with sharing class ReportPartnerTrialistController {
public List<Analytic_Report__c> PartnerReports {get; set;}
public boolean showSendEmailButton {get; set;}
public boolean showRecalculateButton {get; set;}
public boolean ArReportEmailSent {get; set;}
public integer previousMonths {get; set;}
public String monthReport {get; set;}
public String yearReport {get; set;}
public date firstDayMonthReport {get; set;}

public ReportPartnerTrialistController() {
  // set month with previousMonths number
  if (previousMonths == null) previousMonths = 0;
  // recalculate button to true
  // showRecalculateButton = true;
}

public List<Analytic_Report__c> getReports() {
 
  firstDayMonthReport = date.today().addMonths(-(1 + previousMonths)).toStartOfMonth();
  // add test flag as no old data can be created from test
  if(Test.isRunningTest() == true){
   firstDayMonthReport = date.today().toStartOfMonth();
  }
  String monthAR = String.Valueof(firstDayMonthReport.month());
     yearReport = String.Valueof(firstDayMonthReport.year());
    
     if (monthAR == '1') monthAR = 'January';
     if (monthAR == '2') monthAR = 'February';
     if (monthAR == '3') monthAR = 'March';
     if (monthAR == '4') monthAR = 'April';
     if (monthAR == '5') monthAR = 'May';
     if (monthAR == '6') monthAR = 'June';
     if (monthAR == '7') monthAR = 'July';
     if (monthAR == '8') monthAR = 'August';
     if (monthAR == '9') monthAR = 'September';
     if (monthAR == '10') monthAR = 'October';
     if (monthAR == '11') monthAR = 'November';
     if (monthAR == '12') monthAR = 'December';
     monthReport = monthAR;
    
  // set display for send email button
  List<Report_Email__c> ReportEmails = new List<Report_Email__c>([Select Id, Name, Analytic_Report__c, Contact__c, Email_status__c, type__c from Report_Email__c where Email_status__c = 'Waiting' and Analytic_Report__r.Month__c = :monthReport and Analytic_Report__r.year__c = :yearReport ]);
       if(ReportEmails.size() > 0){
        showSendEmailButton = true;
        showRecalculateButton = true;
       }else{
        showSendEmailButton = false;
        showRecalculateButton = false;
       }

  PartnerReports = new List<Analytic_Report__c>([Select Referring_Partner__c,Referring_Partner__r.Name, Partner_City__c, Month__c, Year__c, Type__c, Patients_who_completed_trial__c,Patients_who_have_not_purchased_products__c,Patients_who_purchased_products__c,Patients_who_started_trial__c,Emails__c, Financial_situation_constraints__c,Non_Compliant__c,Not_an_immediate_priority__c,Other__c,Average_Trial_Time__c, Number_of_Patients_not_contactable__c, Purchased_from_partner__c, Purchased_from_an_other_partner__c,Purchased_from_internet__c, Patients_who_discontinued__c, Purchased_from_government__c, Purchased_from_second_hand__c   
   from Analytic_Report__c
   where  Type__c = 'Partner Trialist Report' and Month__c =: monthReport and Year__c = :yearReport
   order by Referring_Partner__r.Name asc ]);
  return PartnerReports;
}

public PageReference sendEmails(){
       List<Report_Email__c> ReportEmails = new List<Report_Email__c>([Select Id, Name, Analytic_Report__c, Contact__c, Email_status__c, type__c from Report_Email__c where Email_status__c = 'Waiting' and Analytic_Report__r.Month__c = :monthReport and Analytic_Report__r.year__c = :yearReport ]);
       List<Note> emailSentNotes = new List<Note>();
       for (Report_Email__c re :ReportEmails ){
        // set the status for the workflow rule to send email using template - the status will be change to sent by the workflow rule
        re.Email_status__c = 'To be sent';
        Note tempNote = new Note();
        tempNote.Title = 'Partner Trialist HTML Email sent - ' + monthReport + ' ' + yearReport;
        tempNote.ParentId = re.Contact__c;
        tempNote.Body = 'Trialist Partner Report \n \n Sent from the Analytic Report record: ' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + re.Analytic_Report__c;
        emailSentNotes.add(tempNote);
       
       }
       // add notes to all contact who email was sent to
       insert emailSentNotes;
      
       update ReportEmails;
       PageReference newpage = new PageReference(System.currentPageReference().getURL());
     newpage.setRedirect(true);
     return newpage;
    }
   
    public PageReference movePreviousMonth(){
       previousMonths++;
     return null;
    }
   
    public PageReference lastMonth(){
       // set previousMonths to 0
       previousMonths = 0;
       return null;
    }
   

  • August 16, 2013
  • Like
  • 0