You need to sign in to do that
Don't have an account?
Michael Carrier
Get lead assignment rules to fire from a Visual force page
Hello All,
I am very new to writing code and am having a hard time getting assignment rules to fire once a lead is entered into a visualforce page. I ahve found a few examples out there where folks suggest DML code, however I am not sure if I can put on the Visual Force page or if I should create a seperate class (or if I should create a trigger to fire after the lead is created). Salesfroce suggested I create a class and gave me the following code:
public Lead sample {get; set;}
public AssignLeadsUsingAssignmentRules(ApexPages.StandardController controller)
{
sample = new Lead();
}
public void LeadAssign() {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.assignmentRuleId= '01Q0m0000006EH9';
sample.setOptions(dmo);
insert sample;
}
Below is my Visual Force page:
<apex:page standardController="Lead" showHeader="false" sidebar="true" extensions="AssignLeadsUsingAssignmentRules">
<apex:form >
<apex:pageBlock title="Lead Information">
<apex:pageBlockSection >
<apex:pageBlockSection >
<apex:inputField value="{!Lead.Lead_Referred_By__c}" required="True"/>
<apex:inputField value="{!Lead.Club2__c}" required="True"/>
<apex:inputField value="{!Lead.company}" required="True"/>
<apex:inputField value="{!Lead.NumberOfEmployees}" required="True"/>
<apex:inputField value="{!Lead.FirstName}" required="True"/>
<apex:inputField value="{!Lead.LastName}" required="True"/>
<apex:inputField value="{!Lead.Phone}" required="True"/>
<apex:inputField value="{!Lead.Email}" required="False"/>
<apex:inputField value="{!Lead.Title}" required="True"/>
<apex:inputField value="{!Lead.Additional_Comments__c}"/>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
My issue is that the CLub2__c field is used to dirive a Territory filed on the lead, the assignemnt rules fires off of the Territory field. Any code, tips , suggestions, prayers are greatly appreciated.
I am very new to writing code and am having a hard time getting assignment rules to fire once a lead is entered into a visualforce page. I ahve found a few examples out there where folks suggest DML code, however I am not sure if I can put on the Visual Force page or if I should create a seperate class (or if I should create a trigger to fire after the lead is created). Salesfroce suggested I create a class and gave me the following code:
public Lead sample {get; set;}
public AssignLeadsUsingAssignmentRules(ApexPages.StandardController controller)
{
sample = new Lead();
}
public void LeadAssign() {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.assignmentRuleId= '01Q0m0000006EH9';
sample.setOptions(dmo);
insert sample;
}
Below is my Visual Force page:
<apex:page standardController="Lead" showHeader="false" sidebar="true" extensions="AssignLeadsUsingAssignmentRules">
<apex:form >
<apex:pageBlock title="Lead Information">
<apex:pageBlockSection >
<apex:pageBlockSection >
<apex:inputField value="{!Lead.Lead_Referred_By__c}" required="True"/>
<apex:inputField value="{!Lead.Club2__c}" required="True"/>
<apex:inputField value="{!Lead.company}" required="True"/>
<apex:inputField value="{!Lead.NumberOfEmployees}" required="True"/>
<apex:inputField value="{!Lead.FirstName}" required="True"/>
<apex:inputField value="{!Lead.LastName}" required="True"/>
<apex:inputField value="{!Lead.Phone}" required="True"/>
<apex:inputField value="{!Lead.Email}" required="False"/>
<apex:inputField value="{!Lead.Title}" required="True"/>
<apex:inputField value="{!Lead.Additional_Comments__c}"/>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
My issue is that the CLub2__c field is used to dirive a Territory filed on the lead, the assignemnt rules fires off of the Territory field. Any code, tips , suggestions, prayers are greatly appreciated.
Visualforce Page changes
All Answers
Visualforce Page changes