• learningsfdcdev
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Wanted to write this post on what the best practice is for trigger architecture pattern. I have heard mixed things.

 

1.  There should only be 1 trigger per object with the trigger context seperated within the trigger to call certain classes.

 

 

2.  An object should have more than 1 trigger with each trigger having  seperate context.

     For example

     -trigger 1:   AccountBeforetrigger with context methods of isInsert, isUpdate etc..

    - trigger 2: AccountAftertrigger with context methods of isInsert, isUpdate etc..

 

Also, if #2 is the preferred approach, should there never be more than 2 triggers per object which seperates the concerns by before and after.

 

Thanks,

 

Right now, I have a selectoptions on my vf page that has several checkboxes. If Checkbox Value 1 is selected, another  input text field is displyed and if unchecked it is hidden again which is wrapped around a div called showfield.  The script below works great but if the value is pre-checked on page load(since it is passed from another page), the textbox should display or not display depending on if it is checked. How can I ensure in visualforce, that my script below runs immediatley after the DOM is loaded? when I did an alert the getchkboxvalue is undefined.....i tried domcontentloaded and that didn't work either, when i tried windows.load the alert boxes said undefined when i tried to output getchkboxvalue value

 

<apex:outputPanel >
                            <apex:selectCheckBoxes onchange="Showdiv(this)" value="{!checkboxes}" required="true" id="checkboxes" >
                            <apex:selectOptions value="{!checkboxes}"/>
                             </apex:selectCheckBoxes>
  </apex:outputPanel>

 

<div id = "showfield" style="display:none;">             
                 <apex:panelGrid columns="2" columnClasses="labelCol,input" styleClass="inputGrid">    
                    <apex:outputLabel id="myfieldId" for="myField" ><span class="required">* </span> myField:</apex:outputLabel>
                    <apex:inputField id="myField" value="{!Lead.myField}" required="false"/>
                </apex:panelGrid>
                </div> 

 

</script>
      function Showdiv(var1){
           var getchkboxvalue=var1.value;
         if(getchkboxvalue=='Checkbox Value 1' && var1.checked==true){
              document.getElementById('showfield').style.display='block';
           }
               if(getchkboxvalue=='Checkbox Value 1' && var1.checked==false){
                    document.getElementById('showfield').style.display='none';
            }
        }
        </script>  
    </body> 

Wanted to write this post on what the best practice is for trigger architecture pattern. I have heard mixed things.

 

1.  There should only be 1 trigger per object with the trigger context seperated within the trigger to call certain classes.

 

 

2.  An object should have more than 1 trigger with each trigger having  seperate context.

     For example

     -trigger 1:   AccountBeforetrigger with context methods of isInsert, isUpdate etc..

    - trigger 2: AccountAftertrigger with context methods of isInsert, isUpdate etc..

 

Also, if #2 is the preferred approach, should there never be more than 2 triggers per object which seperates the concerns by before and after.

 

Thanks,

 

Right now, I have a selectoptions on my vf page that has several checkboxes. If Checkbox Value 1 is selected, another  input text field is displyed and if unchecked it is hidden again which is wrapped around a div called showfield.  The script below works great but if the value is pre-checked on page load(since it is passed from another page), the textbox should display or not display depending on if it is checked. How can I ensure in visualforce, that my script below runs immediatley after the DOM is loaded? when I did an alert the getchkboxvalue is undefined.....i tried domcontentloaded and that didn't work either, when i tried windows.load the alert boxes said undefined when i tried to output getchkboxvalue value

 

<apex:outputPanel >
                            <apex:selectCheckBoxes onchange="Showdiv(this)" value="{!checkboxes}" required="true" id="checkboxes" >
                            <apex:selectOptions value="{!checkboxes}"/>
                             </apex:selectCheckBoxes>
  </apex:outputPanel>

 

<div id = "showfield" style="display:none;">             
                 <apex:panelGrid columns="2" columnClasses="labelCol,input" styleClass="inputGrid">    
                    <apex:outputLabel id="myfieldId" for="myField" ><span class="required">* </span> myField:</apex:outputLabel>
                    <apex:inputField id="myField" value="{!Lead.myField}" required="false"/>
                </apex:panelGrid>
                </div> 

 

</script>
      function Showdiv(var1){
           var getchkboxvalue=var1.value;
         if(getchkboxvalue=='Checkbox Value 1' && var1.checked==true){
              document.getElementById('showfield').style.display='block';
           }
               if(getchkboxvalue=='Checkbox Value 1' && var1.checked==false){
                    document.getElementById('showfield').style.display='none';
            }
        }
        </script>  
    </body>