+ Start a Discussion
RDN_LHRRDN_LHR 

DatabaseDMLOptions Error

Has anyone used DatabaseDMLOptions?

 

When creating a case via a visualforce page with standard and extension controller, I would like the default assignment rule to fire.

 

I cut and paste the following out of the documentation as shown here:

 

 DatabaseDMLOptions dmo = new Database.DMLOptions();

 dmo.assignmentRuleHeader.useDefaultRule= true;

 

and pasted it in my code as  :

 

 

DatabaseDMLOptions dmo = new Database.DMLOptions();

dmo.assignmentRuleHeader.useDefaultRule= true; 

 

Case c = new Case();

 

c.SuppliedName = 'myName';

c.SuppliedEmail = 'my@emailaddy.com';

c.SuppliedCompany = 'myCompany';

 

c.setOptions(dmo);

 

insert c;

 

---

 

When I try to save this version of the code in Eclipse, it moans about the second line, with the following: "Save error: unexpected token: dmo.assignmentRuleHeader.useDefaultRule".

 

So then I checked the class itself, and it is saved against API version 15.  I can't see how I've done anything wrong since I cut and pasted the thing exactly as in the documentation.

Message Edited by RDN_LHR on 03-02-2009 06:35 AM
werewolfwerewolf
Does it work if you give it an explicit assignmentRuleId?
werewolfwerewolf

And don't you mean

 

Database.DMLOptions dmo = new Database.DMLOptions();

 

You're missing the . in that first word there.

RDN_LHRRDN_LHR

It's still moaning at the same thing, the second line,.

 

Whether it's

 

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.assignmentRuleId= '<with rule Id here>';

 

or

 

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;

RDN_LHRRDN_LHR

By the way, what do you guys do if you put up a query like this and nobody has an answer, like in this situation?

werewolfwerewolf
Contact Salesforce.com Support.  If you have premier support then file a case with Developer Support instead.
werewolfwerewolf
Oh hey, what endpoint are you using?  If you're still using version 14.0 of Apex it won't register that DMLOptions exists -- you'll want to use 15.0 instead.
RDN_LHRRDN_LHR

I thought of the v14 problem.  In Eclipse, I only get the option of v14 even though I just updated it in the last week and a half.

 

So I fired up my browser and logged in to the development org I use.  I went through setup to the classes area and sure enough, it says v15 there.  That's what prompted me to post in the first place.  So I decided to edit the class right there through the UI and uncomment the problem lines and save.  And I still get the same error.

 

I was really hoping there was some little stupid error I was making.

werewolfwerewolf
Actually you can change the endpoint of your Apex code by clicking on the little Metadata tab at the bottom there.  So you'd have to change it to 15.  But as you already know, there's a separate issue with DMLOptions going on right now.