• BroncoBoy
  • NEWBIE
  • 290 Points
  • Member since 2013
  • Salesforce CRM Developer
  • Jackson

  • Chatter
    Feed
  • 3
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 45
    Replies
(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)
"The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period: 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater"

When we're talking about batch Apex, for example, are we just talking about start(), execute(), finish() methods being applied to that limit or are all methods - even custom methods - also included in that figure as well?

Also is there a way to see how close we are getting to that limit every day?  I looked at the Limits class but didn't see any direct methods there.  We have a couple of huge batch classes that run once a week and I want to make sure we're not getting too close to that limit.
Hello all, 
 
I'm trying to run the Dataflow and getting this error: 
 
Error executing node 133: Invalid schema: Error, Invalid key name: %!(EXTRA string=WhatId(Account).Name) (02K32000000CdmREAS_03C32000000TNDQEA4)
 
I can't find a knowledge article on this particular error. 
 
Can anybody speak to this? 
 
Thanks in advance. 
Not sure if this is possible but I'm interested in creating a stacked vertical bar chart with 2 Y axes as follows:

1.  It has last 6 months on the X axis, e.g. January - June
2.  It has 2 Y Axes: on the left Sales in $$, on the right Applications - both as a decimal
3. For each month you have Product A Applications bar stacked on Product A Sales bar and then  Product B Applications bar​ stacked on Product B Sales bar.

So essentially it's like stacking/superimposing one bar chart on top of another and adding an extra y axis.  Is this even possible?  Thanks in advance! 
Bronco
Not sure why I 'm getting a null pointer error here in the batch process, any thoughts are appreciated :)

Code
public Database.QueryLocator start(Database.BatchableContext BC)  
{
    String query = 'SELECT Id,  (SELECT ContactId, IsPrimary FROM OpportunityContactRoles ORDER BY IsPrimary DESC) FROM Opportunity WHERE LastModifiedDate = LAST_N_DAYS:365';
    return Database.getQueryLocator(query); 
}

public void execute(Database.BatchableContext BC, List < sObject > s)
{
    List < Opportunity > oppsToUpdate = new List < Opportunity > ();
    for (sObject ssss: s)
    {
        Opportunity o = (Opportunity) ssss;
        List < OpportunityContactRole > opptys = new List < OpportunityContactRole > ();
        opptys = (List < OpportunityContactRole > ) o.getsobjects('OpportunityContactRoles'); //o.getsobjects will return a List<SObject>, in the same line we cast those into List<OpportunityContactRole>

        for (OpportunityContactRole optt: opptys) // HERE IS WHERE THE ERROR IS.  LOOPING THROUGH SUB QUERY LIST
        {
            String contId = '';
            contId = String.ValueOf(optt.ContactId);
            if (!String.IsBlank(contId))
            {
                o.Primary_Contact_Id__c = contId;
                oppsToUpdate.add(o);
                break;
            }
        }
    }

    update oppsToUpdate;

}
Anyone know how to re-format a number to currency (or at least have the commas) and display on a apex:barSeries chart?

Right now the left axis is displaying several #'s, for example: 10000.   I would prefer 10,000 or, even better, $10,000.

The source data is coming from a number type field from a custom object.  I'm also wondering if I convert the field to type: currency if that would help?

Thanks in advance!
Bronco
Here's my SOQL:
SELECT Summary_Id__c, SUM(EA_App_Count__c) appCount FROM CustomObject__c WHERE Full_Date__c = THIS_MONTH GROUP BY Summary_Id__c';

Here's what I'm trying to do:
Trying to run this SOQL 6 separate times, based on the current month, once per month for the previous 6 months date range. So, in essence, after each run, the filter date range would dynamically change look something like:
  1. WHERE Full_Date__c = THIS_MONTH -1 //Previous month
  2. WHERE Full_Date__c = THIS_MONTH - 2 //2 months ago
  3. WHERE Full_Date__c = THIS_MONTH - 3 //3 months ago
  4. WHERE Full_Date__c = THIS_MONTH - 4 //4 months ago
  5. WHERE Full_Date__c = THIS_MONTH - 5 //5 months ago
  6. WHERE Full_Date__c = THIS_MONTH - 6 //6 months ago
So here's my dillema:  how to produce a date range that is the equivalent to THIS_MONTH - #?  Is there a Date Literal or function that I can use?

Thanks in advance for any help you can offer!
-Bronco
Hi ,

My user running his mobile Salesforce1 then showing this Error.

"There's a problem saving this record. You might not have permission to edit, or might have been deleted or archived."

​I also checked his profile, he is Salesforce 1 User. How can help this user to edit/ Save  via Salesforce1 on the case ?
Ulitmate Goal:
Create a map of lists (contactIdsToOpportunities)  which maps a contact id to the list of opportunities that contact is associated with within the OpportunityContactRole object - all based on a limited # of contact id's, only opportunities within the last 30 days.

As I'm trying to access the subquery field values to build my map of lists, its generating the following error: 
Invalid aggregate relationship OpportunityContactRole for Opportunity


I'm trying to use this approach:  http://www.infallibletechie.com/2012/04/how-to-get-subquery-field-value-using.html

I'm grateful for any help, so thanks in advance!
-Bronco

CODE:
set <Id> evtsContactIds = new set <Id>{'0035000000yim1c’,’0035000000cin2f’};//insert contacts id's here
map <Id, List <Opportunity>> contactIdsToOpportunities = new Map <Id, List <Opportunity>>();

for (Opportunity o: [SELECT Id, CloseDate, Description, Name, (SELECT ContactId FROM OpportunityContactRoles WHERE ContactId IN: evtsContactIds) FROM Opportunity WHERE CloseDate >= LAST_N_DAYS: 30 AND Id IN(SELECT OpportunityId FROM OpportunityContactRole WHERE ContactId IN: evtsContactIds) ORDER BY CloseDate DESC])
{
    List < OpportunityContactRole > opptys = new List < OpportunityContactRole > ();
    opptys = o.getSObjects('OpportunityContactRole'); //very rarely used method, but this gets the records from the subquery, 
    Id oppContId;
    for (OpportunityContactRole opt: opptys)
    {
        oppContId = opt.ContactId;

        if (contactIdsToOpportunities.containsKey(oppContId))
        {
            List < Opportunity > contactsOpportunities = contactIdsToOpportunities.get(oppContId);
            if (contactsOpportunities.size() <= 3) //this is what determines that the code will only return the latest 3 opportunities
            {
                contactsOpportunities.add(o);
                contactIdsToOpportunities.put(oppContId, contactsOpportunities);
            }
        }
        else
        {
            contactIdsToOpportunities.put(oppContId, new List <Opportunity>{o});
        }
    }
}
I have a Task trigger on which I'm tyring to also reset the checkbox values to be unchecked in the before context but still use the initial values (prior to resetting) in the after context.  The idea is to reset them without having to execute a DML update later on in the trigger.  The problem is that the values are not being captured in the before context - they are all remaining false, so I can't use them for logic in the after context.  Thank you in advance for any help you can provide.

Code
 trigger EmailTaskDescription on Task(before insert, after insert, before update, after update)
 {
     Boolean nofityRIW = false;
     Boolean nofityREW = false;
     Boolean nofityBDC = false;
     Boolean nofityGIW = false;
     Boolean nofityGEW = false;

     if (trigger.isBefore)
     {
         Task tt = Trigger.new[0];
         //capture checkbox selections
         nofityRIW = tt.Notify_R_IW__c;
         nofityREW = tt.Notify_R_EW__c;
         nofityBDC = tt.Notify_BDC__c;
         nofityGIW = tt.Notify_G_IW__c;
         nofityGEW = tt.Notify_G_EW__c;
         //reset checkbox selections to unchecked
         tt.Notify_R_IW__c = false;
         tt.Notify_R_EW__c = false;
         tt.Notify_BDC__c = false;
         tt.Notify_G_EW__c = false;
         tt.Notify_G_IW__c = false;
     }
     if (trigger.isAfter)
     {
        //use initial values to execute logic 
        if (nofityRIW)
         {

         }
         else if (nofityREW)
         {

         }
     }
 }
Hi
I want to understand a specific concept.
I have created​​ 2 batch apex classes say account and contact and now I need to run contact class only after account class fully completes(without any errors of course).

I schedule account class & then contact class, so when I click setup --> jobs --> scheduled jobs,   I can see both these jobs

As per documentation order of execution of jobs is not guaranteed.

so how do I make sure that contact batch job executes only successful execution of account batch job.

please be specific in replies.

sonali​​​
My Visualforce page has an extension has a public method: TopOneHundred();  which returns a JSON string.  Though there are ways to execute the class method using Javascript, I'm not sure how to obtain the returned JSON string for use in my Javascript. The TopOneHundred() method uses other variables from the extension in order to return the correct string.  This is done because the user is interacting with some picklists on the VF page and we're executing the TopOneHundred() method using the picklists choices. 

Because of this, I can't use Javascript remoting nor can I use the AJAX toolkit/sforce.apex.execute method because both require static keywords and the instance variables are not visible to static methods.  I'm greatful for any advice.

FYI The JSON string is used to populate a Datatables  (https://datatables.net/" target="_blank) table on the VF page.
 
I'm using a couple of functions for filling a list of contacts.   This is done by passing a list of custom BD__c object records to another function (retrieveTopOneHundred) which, in short, uses the BD__c objects to retrieve a list of contacts.  Problem I'm trying to solve:  I want to keep fetching contacts using the retrieveTopOneHundred function until the contactsListB list reaches 100 contacts.  How can I rewrite the code below so that I can do this without having to write a bunch of nested "if(contactsListB.size() < 100)...find more contacts based on the next set of BD__c records"?  I was hoping to use a Do While loop or something simple, but I just couldn't arrive at anything that worked. Thanks in advance for your help!

CODE:
public String TopOneHundred()
{
    List < sObject > bd = StdSetControllerBD.getRecords();
    List < Contact > contactsListB = retrieveTopOneHundred(bd);
    if (contactsListB.size() < 100)
    {
        StdSetControllerBD.next(); //if we have less than 100 contact records then we will go get more by repeating the process, this time with the next set of bd records in the StdSetControllerBD
        List < BD__c > nextRoundOfBdRecords = new List < BD__c > ();
        for (sObject sob: StdSetControllerBD.getRecords())
        {
            BD__c sobd = (BD__c) sob;
            nextRoundOfBdRecords.Add(sobd);
        }
        contactsListB.addAll(retrieveTopOneHundred(nextRoundOfBdRecords));
        if (contactsListB.size() < 100)
        {
            StdSetControllerBD.next(); //if we have less than 100 contact records then we will go get more by repeating the process, this time with the next set of bd records in the StdSetControllerBD
            List < BD__c > thirdRoundOfBdRecords = new List < BD__c > ();
            for (sObject sob: StdSetControllerBD.getRecords())
            {
                BD__c sobdd = (BD__c) sob;
                thirdRoundOfBdRecords.Add(sobdd);
            }
            contactsListB.addAll(retrieveTopOneHundred(nextRoundOfBdRecords));
        }
    }

    String contactsJSON = JSON.serializePretty(contactsListB);
    return contactsJSON;​
}