• 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?

 

Hi,

 

I have a background job that needs to run every few minutes to populate a database (there are multiple database and HTTP calls, so it needs to be run in increments to stay under Salesforce limits), but the Salesforce setup page doesn't allow scheduling jobs except weekly or monthly.

 

Is there a way around this? I was thinking of having the job get the current time, add 5 minutes, and then schedule the next job before it does its work.

 

Are there better solutions?

 

Few questions:

I have a class with 'State' and 'Number'. The combination should be unique, and should be the Name field for the table. I'm hitting some road blocks that I suspect are built-in limitations of SF:

 

  1. Is there a way to make the Name Field a formula? If there is, I haven't found it.
  2. Is there a way to require the Name Field to be unique?
  3. Is there a way to make any Formula Field unique?

One work-around would be using auto-increment for the Name, but this will show up on Lookup Fields, and that's a deal killer. Any suggestions?

Another would be a Trigger that sets the Name before the district is saved and checks for uniqueness. This seems a lot of work for what should be something easy, but I could do it.

 

Is there an elegant approach. What have people tried?

I'm looking for an APEX method that tells me if an APEX object 'is a kind of' object or failing that, to get the Class Name.

 

Psuedo-code:

 

class A {

};

class B extends A {

};

class C extends A {

};

 

function some_function(A aobj) {

  if (a.isKindOf(B)) {

     // do something with B

  } else if (a.isKindOf(C)) {

     // do something with C

 }

 

Thanks!

 

 

 

 

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?

 

 

Is there a way to check if an Apex program is running asynchronously (e.g. through @future)?

Hi,

 

I created a custom object (Districts), and would like to add it to the home page along with Organizations, Contacts, etc. How do I do this?

 

Districts are initialized by callouts, but also by a program that runs and updates all the districts through a web service. How can I add a button or link to the home page to launch the program?

 

Thanks

 

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?

 

 

 

 

There is plenty of SF documentation on creating SF web services, but not much on accessing web services from SF. What API do I use to parse the JSON?

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?