+ Start a Discussion
MrutyunjayMrutyunjay 

Assignment rule not fire in case controller extension

I have created custom case page overriding standard functionality through controller extension

 

and I want to fire assignment rule conditionally

 

my code is here

 **************************************************

public class caseextension
{
private  Case case1;
public boolean assrulevalue;
public caseextension(ApexPages.StandardController stdController)
{
this.case1= (Case)stdController.getRecord();


}
public PageReference save()
{

AssignmentRule assgn=[Select Name, Id From AssignmentRule  where name='Testassign'];
string id=assgn.id;
if(assrulevalue==true)
{
database.DMLOptions dmo = new database.DMLOptions();
dmo.AssignmentRuleHeader.assignmentRuleId=id;
 dmo.AssignmentRuleHeader.useDefaultRule= false;
case1.setOptions(dmo);
   //mailerror('testing');
}
//mailerror('testing'+id);

 insert case1;
//database.insert(case1, dmo);
PageReference pageRef = new PageReference('/' + case1.id);
pageRef.setRedirect(true);
return pageRef;

}

public boolean getassrule()
{
    return assrulevalue;
}
public void setassrule(boolean value)
{
    assrulevalue=value;
}

**********************************************************

 

So what wrong with this code.

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf
What happens if you turn on DMLOptions.EmailHeader.triggerUserEmail?

All Answers

tmatthiesentmatthiesen
Salesforce.com development is looking into this.  It appears there is an issue with the dmloptions case assignment.  Can you log a case on your end and attach it to this thread?
SaaspertSaaspert

I am also having same issue. I have built a visualforce Case page based on custom controller and not able make auto assignment work using dmloptions.

 

This Case page is exposed to customer portal users.

 

any ETA on when this would be fixed ? any workarounds ? e.g. set a "Assign using active assignment rules" field to true before upserting a case ?

 

 

VikasVikas

Hi there,

 

By When Salesforce Development Team is expected to fix this problem?

 

Any insight will be helpful to know and set expectations with my team & customer.

 

Thank you,

 

/Vikas Arora

RDN_LHRRDN_LHR

I guess that's a bit of a relief because I've been going mad with this.  Is there anywhere where Salesforce.com have officially acknowledged this in writing where us regular folk can see?  SFDC have a way of taking their sweet time on these sorts of bugs.

werewolfwerewolf

Message boards to the rescue!  (well, sort of). 

 

I was also trying to debug this same issue with some very similar code of my own until I got it in my head to go search on DMLOptions and I found this. tmatthiesen, can you update this board when the bug is fixed?  Thx.

RDN_LHRRDN_LHR
So guys ... any workarounds out there you can suggest?
MarkSilberMarkSilber
I have officially logged a bug with my Premier Support rep as this has been driving me nuts too. Hopefully I will get some sort of ETA on a fix and will post it.
RDN_LHRRDN_LHR

I was told that this was scheduled to be fixed last Friday.  It seems to be fixed, but while my assignment rules are assigning properly, they're not sending out the assignment emails.

 

Maybe it's fixed but only partially??  Anyone else tried this lately and received assignment emails?

werewolfwerewolf
What happens if you turn on DMLOptions.EmailHeader.triggerUserEmail?
This was selected as the best answer
RDN_LHRRDN_LHR
Yes!  It now works with dmo.EmailHeader.triggerUserEmail = true;

 

I'd put on dmo.EmailHeader.triggerAutoResponseEmail = true;

 

Not quite the same thing!

 

jduhlsjduhls
Wait, you're saying assignmentRuleHeader.useDefaultRule = true works if you also use DMLOptions.EmailHeader.triggerUserEmail = true? Please respond soon - I'm slowly losing my mind.
werewolfwerewolf
There are 2 different questions in this thread.  The first was about assignmentRuleHeader.useDefaultRule (which was not working but to my knowledge is fixed now).  The second is about triggering emails.  They're 2 separate settings in DMLOptions.
MarkSilberMarkSilber
Here's a snippet of code we just got working for "enhanced web2lead" using Sites. It is firing both the assignment and auto-response rules. There are probably other ways to accomplish this -- but it is working for us.

string id =[Select Name, Id From AssignmentRule where name='Lead Assignment'].id; database.DMLOptions dmo = new database.DMLOptions(); dmo.AssignmentRuleHeader.assignmentRuleId=id; dmo.AssignmentRuleHeader.useDefaultRule= false; dmo.EmailHeader.triggerUserEmail = true; dmo.EmailHeader.triggerAutoResponseEmail = true; NewLead.setOptions(dmo); insert NewLead;

 


jduhlsjduhls

My issue can be found here - i'm trying to use DMLOptions in a trigger:

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=15118