• Brig Larimer 10
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I've done a lot of reading about database.dmloptions, assignmentruleheader, etc. the past week or so, but am unable to find a simple answer to a few questions that continue to linger:

1) I have some apex logic built to facilitate lead assignment. I would like for this logic to respect if the user checks "assign using active assignment rules", and to possibly not fire (i.e. return;) when this is the case. How can I check whether this option was enabled by the user on lead insert/update in apex?

2) After getting an affirmative result from #1, I would like to evaluate whether the lead would actually be assigned by the assignment rule after evaluation. This is an important step as I will still want my logic to fire if the assignment rules all evaluate to be false. How can I perform this check? I suppose I could insert a test lead using the assignment rule, query the result, then delete the test lead, but this seems perhaps more DML-intensive than it needs to be...

3) Additionally, if I did decide in certain cases that after detecting this option, I wanted to undo/disable this (despite the user's preference), how could this be done? I have attempted to use this segment on a before trigger, which has no effect:

for (lead l : trigger.new)
{
    database.dmloptions dmo = new database.dmloptions();
    dmo.assignmentRuleHeader.useDefaultRule = false; // (attempt 1)
    dmo.assignmentRuleHeader.assignmentRuleId = null; // (attempt 2)
    l.setOptions(dmo);
}

Any and all help appreciated!

Thanks much.
I've done a lot of reading about database.dmloptions, assignmentruleheader, etc. the past week or so, but am unable to find a simple answer to a few questions that continue to linger:

1) I have some apex logic built to facilitate lead assignment. I would like for this logic to respect if the user checks "assign using active assignment rules", and to possibly not fire (i.e. return;) when this is the case. How can I check whether this option was enabled by the user on lead insert/update in apex?

2) After getting an affirmative result from #1, I would like to evaluate whether the lead would actually be assigned by the assignment rule after evaluation. This is an important step as I will still want my logic to fire if the assignment rules all evaluate to be false. How can I perform this check? I suppose I could insert a test lead using the assignment rule, query the result, then delete the test lead, but this seems perhaps more DML-intensive than it needs to be...

3) Additionally, if I did decide in certain cases that after detecting this option, I wanted to undo/disable this (despite the user's preference), how could this be done? I have attempted to use this segment on a before trigger, which has no effect:

for (lead l : trigger.new)
{
    database.dmloptions dmo = new database.dmloptions();
    dmo.assignmentRuleHeader.useDefaultRule = false; // (attempt 1)
    dmo.assignmentRuleHeader.assignmentRuleId = null; // (attempt 2)
    l.setOptions(dmo);
}

Any and all help appreciated!

Thanks much.