• Riothamus
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 9
    Replies

I have a trigger and associated apex classes that work correctly in Test, but give different (incorrect) results in Production. After going through each Apex file and comparing them in Production and Test, they appear to be identical.

 

What could cause this? What is the best way to debug?

 

What I'd like to do is just delete the Apex files from Production, and then upload a complete change set. How do I do this?

 

I'm modifying a trigger that I wrote to fire during an insert, as well as an update. When processing an update, the object returend from Trigger.new is NULL, and I get a NULL pointer exception. How can I get the object being inserted?

 

I tried it using after insert, and before insert. They both fail:

 

// set district when Account is inserted or updated

trigger AccountDistrictTrigger on Account (after insert, before update) {

    // run trigger on update object(s)
   AccountDistrictUpdater updater = new AccountDistrictUpdater();
   for (Account account: Trigger.new) {
     updater.executeTrigger(account);  // FAILS, account IS NULL
   }
}

 

// set district when Account is inserted or updated
trigger AccountDistrictTrigger on Account (before insert, before update) {

    // run trigger on update object(s)
   AccountDistrictUpdater updater = new AccountDistrictUpdater();
   for (Account account: Trigger.new) {
     updater.executeTrigger(account);  // FAILS, account IS NULL

   }
}

 

How do I get the object?

 

Hi,

I have an Apex program that loops through database records, makes a web service call for each, and stores the result in the record. The web services uses a token which expires after 24 hours, so a record may make up to 3 web service calls -- 1 to fail, 1 to get the token, and 1 to succeed.

 

From my understanding SalesForce limits web service calls to 10 per database transaction so as a brute-force method, I am doing an update for each record like this:

 

// initialize wrapper, scope
AccountWrapper wrapper = new AccountWrapper();
List<Account> scope = [SELECT Id, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode FROM Account LIMIT 10];

// get districts
for (Account account: scope) {
wrapper.getDistrict(account, this.api);
update scope; // update scope to stay at or under Transaction Web Services governor limit
}

 

The Http web service requests are in wrapper.getDistrict. When I run this, I get a CalloutException:

 

recSystem.CalloutException You have uncommitted work pending. Please commit or rollback before calling out

 

My guess is that the update scope is not committing the transaction. How do I do a commit, or is there a better approach?

This method gets an Account object using an object_id, but it is throwing an exception. I know the object_id exists, because I get it from an Account object stored in the database (the code is used in an @future method, so I can't use the object).

 

Why would this be failing? Is it syntax in the SELECT statement?

 

protected override object getObjectById(Id object_id) {
  List<Account> account_scope = [SELECT Id FROM Account Where Id = :object_id];
  return account_scope.size() == 0 ? null : account_scope.get(0);

}

 

 

Hi,

 

I'm using triggers to call a Web Service to lookup an address every time the address changes, but I get the error:

 

System.CalloutException Callout from triggers are currently not supported.(line 124)

 

 

Line 124 is sending the HttpRequest. Is there a work-around?