• dwick
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies

Is it possible to only update after the very last batch has been proccessed in a batch apex job?  I'm using a stateful batch to determine the mean, UCL, and LCL of a large dataset.  What I was hoping to do was have this job run every night, and by tracking the field history be able to report/graph on the moving average of these values.

 

My first thought was to assign Database.countQuery / [batchsize] to a variable allowing me to check if i was on the last batch within the execute method.  Unfortantly, it doesn't appear that this is allowed.

 

Any suggestions would be greatly appreciated.

 

Dave

  • June 12, 2010
  • Like
  • 0

Hi,


Currently I have an anonymous block scheduled to run everything, however I've hit a brickwall as for as script statements goes.  The script parses a number of records for patterns in the data.  This requires a number of different loops, and as a result ~10,000 records quickly balloon into 200,000 script statements.  My question is, is this something that can be solved via the database.batchable interface, or am I still limited to a number of script statements.  I know I can query 5 million records from the batachable interface, but am I limited to how much I operate on these records?  Any advice would be greatly appreciated.

 

David

  • June 01, 2010
  • Like
  • 0

Hi,

I have a master-detail relationship between 2 sObjects, we'll call them master__c and detail__c to make things easier.  Here's what I'm doing:

 

 

list<detail__c> lDetail = Database.Query('SELECT ... WHERE filterCondition');

 The reason for the use of database.query is the query string is actually determined dynamically.

 

Later on in the class, I would like to retrieve the Id of master__c within a particular row of the list.

 

 

sID = lObject[i].get(master__c),

Error: Compile Error: Variable does not exist: master__c

 

 

sID = lObject[i].get(lObject[i].master__c)

Error: Compile Error: Field expression not allowed for generic SObject at line 58 column 83

 

Any ideas here?  It's probably something simple, I can never seem to find the documentation I need.

 

 

 

 

 

 

  • April 18, 2010
  • Like
  • 0

Hi,

When bulk inserting from a csv file my dateTime fields show the correct date, but the time is always 8:00PM for some reason.  Any idea why this is happening?

 

The value in the csv is as follows: 4/2/2010  4:27:00 AM

 

Thanks,


Dave

  • April 14, 2010
  • Like
  • 0

Hi,

I have a custom apex class (which works properly when executed anonymously through the IDE) and would like to be able to invoke the class with the click of a button on a visual force page.  I have a feeling it's really simply, but i just can't seem to figure it out.

 

Here's what I have so far:

 

 

<apex:page >
<apex:enhancedList type="SPC_Settings__c" height="358" rowsPerPage="10" id="SPCSettings" />
<apex:form >
<br />
<apex:commandButton style="float:right;" action="sforce.apex.execute('SPCSettingsUpdate',{},{}" value="Update" id="btnUpdate" />
</apex:form>
</apex:page>

 

Any help would be greatly appreciated!

 

  • April 13, 2010
  • Like
  • 0

When importing records to a master-detail field it seems salesforce requires it be in the form of an id ('a0MQ0000000KYyJ' for example), however my csv file contains the primary key in string form ('R1005').  Is there a means of retrieving the id by using the string form of the key and still using the dataloader?  I'd like to stay away from programming my own loader with the API if i can.

  • April 09, 2010
  • Like
  • 0

Hi,

 

I'm attempting to update a field after insert based on a simple calculation between to objects with a master-detail retationship.  I was under the impression I could not use a forumla for this, but feel free to correct me.

 

Here's the code:

 

 

trigger ComputeTotalSamples on Jobs__c (after insert) {
        for(Jobs__c j: trigger.new) {
            j.TotalSamples__c = j.BatchCount__c * j.ProtocolName__r.BatchSize__c;
            update j;
        }
}

 and the error:

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger ComputeTotalSamples caused an unexpected exception, contact your administrator: ComputeTotalSamples: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.ComputeTotalSamples: line 3, column 51

 

Any help would be greatly appreciated.

 

Dave

 

  • April 08, 2010
  • Like
  • 0

Hi,


Currently I have an anonymous block scheduled to run everything, however I've hit a brickwall as for as script statements goes.  The script parses a number of records for patterns in the data.  This requires a number of different loops, and as a result ~10,000 records quickly balloon into 200,000 script statements.  My question is, is this something that can be solved via the database.batchable interface, or am I still limited to a number of script statements.  I know I can query 5 million records from the batachable interface, but am I limited to how much I operate on these records?  Any advice would be greatly appreciated.

 

David

  • June 01, 2010
  • Like
  • 0

Hi,

I have a master-detail relationship between 2 sObjects, we'll call them master__c and detail__c to make things easier.  Here's what I'm doing:

 

 

list<detail__c> lDetail = Database.Query('SELECT ... WHERE filterCondition');

 The reason for the use of database.query is the query string is actually determined dynamically.

 

Later on in the class, I would like to retrieve the Id of master__c within a particular row of the list.

 

 

sID = lObject[i].get(master__c),

Error: Compile Error: Variable does not exist: master__c

 

 

sID = lObject[i].get(lObject[i].master__c)

Error: Compile Error: Field expression not allowed for generic SObject at line 58 column 83

 

Any ideas here?  It's probably something simple, I can never seem to find the documentation I need.

 

 

 

 

 

 

  • April 18, 2010
  • Like
  • 0

Hi,

I have a custom apex class (which works properly when executed anonymously through the IDE) and would like to be able to invoke the class with the click of a button on a visual force page.  I have a feeling it's really simply, but i just can't seem to figure it out.

 

Here's what I have so far:

 

 

<apex:page >
<apex:enhancedList type="SPC_Settings__c" height="358" rowsPerPage="10" id="SPCSettings" />
<apex:form >
<br />
<apex:commandButton style="float:right;" action="sforce.apex.execute('SPCSettingsUpdate',{},{}" value="Update" id="btnUpdate" />
</apex:form>
</apex:page>

 

Any help would be greatly appreciated!

 

  • April 13, 2010
  • Like
  • 0

When importing records to a master-detail field it seems salesforce requires it be in the form of an id ('a0MQ0000000KYyJ' for example), however my csv file contains the primary key in string form ('R1005').  Is there a means of retrieving the id by using the string form of the key and still using the dataloader?  I'd like to stay away from programming my own loader with the API if i can.

  • April 09, 2010
  • Like
  • 0

Hi,

 

I'm attempting to update a field after insert based on a simple calculation between to objects with a master-detail retationship.  I was under the impression I could not use a forumla for this, but feel free to correct me.

 

Here's the code:

 

 

trigger ComputeTotalSamples on Jobs__c (after insert) {
        for(Jobs__c j: trigger.new) {
            j.TotalSamples__c = j.BatchCount__c * j.ProtocolName__r.BatchSize__c;
            update j;
        }
}

 and the error:

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger ComputeTotalSamples caused an unexpected exception, contact your administrator: ComputeTotalSamples: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.ComputeTotalSamples: line 3, column 51

 

Any help would be greatly appreciated.

 

Dave

 

  • April 08, 2010
  • Like
  • 0