function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AdnanAdnan 

Force Site Assignment Rule

Hi,

 

I have a Force site form which creates lead on submit. I also have a assignment rule, but the issue I am facing is when a leads comes in it is not going through the assignment rule. Instead it is being assigned to the created by user (Guest user License). I have spoken to SF and they also do not have the answer. I would like to know if there is a way to force the class to go through the assignment rule? I am not a coder :(

 

Below is my class. Any assistance is appreciated.

 

 

public class myWeb2LeadExtension {

    private final Lead weblead;
    
    public myWeb2LeadExtension(ApexPages.StandardController stdController) {
       weblead = (Lead)stdController.getRecord();
    }
    
     public PageReference saveLead() {
       try {
       insert(weblead);
       }
       catch(System.DMLException e) {
           ApexPages.addMessages(e);
           return null;
           
           

       }
       PageReference p = Page.Thankweb2lead;
       p.setRedirect(true);
       return p;
     } 
}

 

 

Thanks

Adnan

 

bob_buzzardbob_buzzard

Looking at these ideas:

 

http://success.salesforce.com/ideaSearchResults?c=09a30000000D9xtAAC&s=10094219#skin=le

 

I don't think you're going to be able to get that behaviour.

 

Is there a particular reason why you have to generate the lead via a controller?  We've tended to use the web to lead functionality for this as that causes the assignment rules to be invoked.

 

 

AdnanAdnan

Thanks for the Reply... The reason for not using web to lead is because, This site link will be put on another site and I do not want to deal with site developer on the other end. I want to have full control over it.

 

I also came across this on the discussion board. I am able to put it in the class without any errors, but still not revoking?

 

 

To enforce Assignment Rules in Apex you'll need to instantiate the Database.DMLOptions class, set the useDefaultRule property of assignmentRuleHeader to True, and finally call a native method on your Lead called setOptions, with the Database.DMLOptions instance as the argument.
The code below demonstrates:
 
// to turn the Assignment Rules on
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
theLead.setOptions(dmo);

 Thanks

Adnan