• crmguy.ax226
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

Hi,

 

I have the following code

 

 

//set the assignment rules to actively route case
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = True;

//fieldsDisabled = true;
Case cse = new Case(
subject = subject,
description = description,
suppliedemail = email,
suppliedname = suppliedname,
product__c = productstring,
operating_system__c = operatingsystemstring,
type = typestring,
lang__c = lang,
origin = 'Email'
);

cse.setOptions(dmo);

system.debug('case info before insert' + cse);
insert cse;

 

 Which "should" trigger the default Case assignment rule, which has one rule

 

(if case.origin = 'email') which is always going toeval to true since i manually set this when inserting it.

 

This does not seem to be working with API version 16.  I will note that I'm trying to do this via an Apex Controller for a Visualforce page, not that it "should" matter.

 

Debug log seems to indicate that the assignment rule piece is being skipped.  Actual behavior is thatthe case is left as assigned to the person that created it (not the default user for when assignment rule fails).  I am also NOT using the standardController for Case, but rather a custom one.  I don't think this should matter either (since I can still save this code to the server without error...), but adding on just in case.

 

Please advise.

 

 

 

Message Edited by paul-lmi on 06-19-2009 07:55 PM
The following code illustrates several bugs in how attributes get bound to a custom component's controller.  From what I read in the discussion (http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=5964) on assignTo, I understand that the attributes will not be available in the controller's constructor.  However,

I've include a test bench that illustrates the following problems:
  1. Default values do not get assigned to the variables.  They are Null when the initial page renders.
  2. Required attributes do get properly bound to the controller's Property but cannot be updated by actions.
  3. If we override the custom getter to ensure that its not null when returned, it initially is rendered as null but after an update is bound but does not increment as you would expect
  4. (What works): Properties that that are only present in the controller and do not get anything assigned to them.
The following 3 source files make up the test bench:
demoComponentBinding.page
BuggedComponentBinding.component
BuggedBindingController.cls

Code:
<apex:page >

<h1>The following demonstrates several bugs in using the assignTo attributes with a custom component</h1>
<ol>
 <li> The convention when I'm assigning values is the following:  Those in the hundreds are assigned via component attributes, while those less than 100 are assigned by the controller</li>
 <li>Default values do not get assigned to the variables.  They are Null.</li>
 <li>Required attributes do get properly bound but cannot be updated by actions.</li>
 <li>If we override the custom getter to ensure that its not null when returned, it initially is rendered as null but after an update is bound but does not increment as you would expect</li>
 <li>(What works): Un assigned attributes that are only present in the controller.</li>
</ol>

<c:BuggedComponentBinding demoTitle="Only Specifying required Attributes, default will not get bound properly"
 RequiredBound="300"/>
<c:BuggedComponentBinding demoTitle="Specifying both required and one default attributes, default will get bound but cannot be updated"
 NotRequiredDefaultBound="100"
 RequiredBound="300"/>
<c:BuggedComponentBinding demoTitle="Only specifying default attribute with custom getter"
 DefaultWithCustomGetter="200"
 RequiredBound="300"/>
<c:BuggedComponentBinding demoTitle="Specifying required and both default attributes, default will get bound but cannot be updated"
 NotRequiredDefaultBound="100"
 DefaultWithCustomGetter="200"
 RequiredBound="300"/>

</apex:page>

 
Code:
<apex:component controller="BuggedBindingController">
 <apex:attribute name="NotRequiredDefaultBound" default="11" assignTo="{!DefaultAssignedAttribute}" type="Integer"
  description="The default attribute does not get bound to the appropriate property of the controller" />
 <apex:attribute name="DefaultWithCustomGetter" default="22" assignTo="{!DefaultAssignedAttributeCustomGetter}" type="Integer"
  description="The default attribute does not get bound to the appropriate property of the controller" />
 <apex:attribute name="RequiredBound" assignTo="{!RequiredAttributeAssigned}" type="Integer" required="true"
  description="This required attribute gets bound, but cannot be updated via ajax calls" />
 <apex:attribute name="DemoTitle" type="string" description="Title of this demo"/>
  
<apex:form >

 <apex:outputPanel id="theTableWrapper" layout="block" title="{!DemoTitle}" style="padding: 10px; border: 1px solid black">
  <apex:panelGrid columns="4" id="theGrid" rules="all" cellpadding="5" width="50%">
   <apex:facet name="caption">
    <h2>{!DemoTitle}</h2>
   </apex:facet>
   <apex:outputText value="Property"/>
   <apex:outputText value="IsNull"/>
   <apex:outputText value="Value from Controller" />
   <apex:outputText value="Value from Component Attribute Reference" />
   
   
   <apex:outputText value="DefaultAssignedAttribute" />
   <apex:outputText value="{!ISNULL(DefaultAssignedAttribute)}" />
   <apex:outputText value="{!DefaultAssignedAttribute}" />
   <apex:outputText value="{!NotRequiredDefaultBound}" />
   
   <apex:outputText value="DefaultAssignedAttributeCustomGetter" />
   <apex:outputText value="{!ISNULL(DefaultAssignedAttributeCustomGetter)}" />
   <apex:outputText value="{!DefaultAssignedAttributeCustomGetter}" />
   <apex:outputText value="{!DefaultWithCustomGetter}" />
   
   <apex:outputText value="RequiredAttributeAssigned" />
   <apex:outputText value="{!ISNULL(RequiredAttributeAssigned)}" />
   <apex:outputText value="{!RequiredAttributeAssigned}" />
   <apex:outputText value="{!RequiredBound}" />
   
   
   <apex:outputText value="InternalAttribute" />
   <apex:outputText value="{!ISNULL(InternalAttribute)}" />
   <apex:outputText value="{!InternalAttribute}" />
   <apex:outputText value="N/A" />
   
  </apex:panelGrid>
  <apex:commandButton action="{!updateValues}" reRender="theTableWrapper" value="Update the Values"/>
 </apex:outputPanel>
</apex:form>
 
</apex:component>

 
Code:
public class BuggedBindingController {
 
 public Integer DefaultAssignedAttribute  {get; set;}
 public Integer DefaultAssignedAttributeCustomGetter  {
  get {
   if( this.DefaultAssignedAttributeCustomGetter == null){
    this.DefaultAssignedAttributeCustomGetter = 20;
   }
   return DefaultAssignedAttributeCustomGetter;
  } set;}
 public Integer RequiredAttributeAssigned  {get; set;}
 public Integer InternalAttribute   {get; set;}
 
 public BuggedBindingController(){
  InternalAttribute = 40;
 }
 
 public PageReference updateValues(){
  if(this.DefaultAssignedAttribute != null){
   this.DefaultAssignedAttribute++;
  }
  if(this.RequiredAttributeAssigned != null){
   this.RequiredAttributeAssigned++;
  }
  this.DefaultAssignedAttributeCustomGetter++;
  this.InternalAttribute++;
  return null;
 }
 
}

 




Message Edited by parkerAPT on 01-15-2009 08:16 AM