• David S
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hello,
I'm new to javascript.  I'm having trouble with the following code in a home page component.   The purpose is to disable the "All Users" list view on the Calendar page:
<script>
	function hideButton() {    
		var saveandNewid = document.getElementsByName('fcf');            
		var saveNewlen = saveandNewid.length;       
		for( var i=0; i< saveNewlen; i++)               
			saveandNewid[i].options[0].disabled=true;     
	}      

	window.onload = hideButton;
</script>

While the script does work, the problem is that it interferes with other standard layout pages in Salesforce, such as the related lists on a page layout stop working.  Is there anything i can do to stop this behavior.   I understand there is the noConflict function available, but no sure how i would use it in this case.

Thanks in advance,
David

Hello.  I have created a trigger to minotor if certain fields are updated in a custom object. If the field is updated it creates a record in another custom object.  Below is the code:

 

trigger CheckFieldUpdate on Obj1__c (before update) {


    List<Obj1__c> stores = trigger.new;
    List<Obj2__c> tasks = new List<Obj2__c>();

    for(Obj1__c s : stores){

        if(s.Field1__c <> trigger.oldMap.get(s.id).Field1__c) {

            Obj2__c tsk = new Obj2__c(
                                Company__c = s.id, 
                                Name = 'Changed Field1 from "'+ trigger.oldMap.get(s.id).Field1__c +'" to ' + '"' + s.Field2__c + '"'
                                );
            tasks.add(tsk);
        }
        
        if(s.name <> trigger.oldMap.get(s.id).name) {
            Obj2__c tsk = new Obj2__c(
                                Company__c = s.id, 
                                Name = 'Changed Field2 from "'+ trigger.oldMap.get(s.id).Field2__c +'" to ' + '"' + s.Field2__c + '"'
                                );
            tasks.add(tsk);
        }    

    if (!tasks.isEmpty()) {
            insert tasks;
    }
} 

 

The code above only checks for 2 fields. What if there are more fields that i need to check, i'm wondering if there is a way to accomplish this in more efficient manner?  Is it possible to create a loop to go though a list of fields?

 

Thanks.

Hello.  

 

I'm trying to modify to code from force.com cookbook, found here,  to render the page detail or related list, based on the user selection of the drop-down field.   I added the drop-down list, but not sure how to grab the selected value and render the outputPanels.   I'm new to VisualForce developement, any assistance is very much appreaciated.

 

My VF page:

<apex:page controller="contactController" showHeader="true" tabStyle="Contact">
<apex:form >

    <select id="selection">
      <option value="Detail">Detail</option>
      <option value="List">List</option>
    </select>

  
    <apex:dataTable value="{!contacts}" var="c" cellpadding="4" border="1">
      <apex:column >
        <apex:facet name="header"><b>Name</b></apex:facet>
        
        <apex:commandLink reRender="detail">{!c.name}
          <apex:param name="id" value="{!c.id}"/>
        </apex:commandLink>
      </apex:column>
      
      <apex:column >
        <apex:facet name="header"><b>Account Name</b></apex:facet>
        {!c.account.name}
      </apex:column>
    </apex:dataTable>
  </apex:form>
  
  <apex:outputPanel id="detail" >
    <apex:detail subject="{!contact}" title="false" relatedList="false"/>
  </apex:outputPanel>
  
  <apex:outputPanel id="list">
     <apex:relatedList list="ActivityHistories"  subject="{!contact}"/>
  </apex:outputPanel>  
  
</apex:page>

 Controller:

 

public class contactController {

   
   public List<Contact> getContacts() {
      return [SELECT Id, Name, Account.Name, Phone, Email
              FROM Contact
              ORDER BY LastModifiedDate DESC LIMIT 10];
   }

  
   public Contact getContact() {
      Id id = System.currentPageReference().getParameters().get('id');
      return id == null ? new Contact() : [SELECT Id, Name
                                             FROM Contact
                                            WHERE Id = :id];
   }
   
}

 

Hello,
I'm new to javascript.  I'm having trouble with the following code in a home page component.   The purpose is to disable the "All Users" list view on the Calendar page:
<script>
	function hideButton() {    
		var saveandNewid = document.getElementsByName('fcf');            
		var saveNewlen = saveandNewid.length;       
		for( var i=0; i< saveNewlen; i++)               
			saveandNewid[i].options[0].disabled=true;     
	}      

	window.onload = hideButton;
</script>

While the script does work, the problem is that it interferes with other standard layout pages in Salesforce, such as the related lists on a page layout stop working.  Is there anything i can do to stop this behavior.   I understand there is the noConflict function available, but no sure how i would use it in this case.

Thanks in advance,
David

Hello.  I have created a trigger to minotor if certain fields are updated in a custom object. If the field is updated it creates a record in another custom object.  Below is the code:

 

trigger CheckFieldUpdate on Obj1__c (before update) {


    List<Obj1__c> stores = trigger.new;
    List<Obj2__c> tasks = new List<Obj2__c>();

    for(Obj1__c s : stores){

        if(s.Field1__c <> trigger.oldMap.get(s.id).Field1__c) {

            Obj2__c tsk = new Obj2__c(
                                Company__c = s.id, 
                                Name = 'Changed Field1 from "'+ trigger.oldMap.get(s.id).Field1__c +'" to ' + '"' + s.Field2__c + '"'
                                );
            tasks.add(tsk);
        }
        
        if(s.name <> trigger.oldMap.get(s.id).name) {
            Obj2__c tsk = new Obj2__c(
                                Company__c = s.id, 
                                Name = 'Changed Field2 from "'+ trigger.oldMap.get(s.id).Field2__c +'" to ' + '"' + s.Field2__c + '"'
                                );
            tasks.add(tsk);
        }    

    if (!tasks.isEmpty()) {
            insert tasks;
    }
} 

 

The code above only checks for 2 fields. What if there are more fields that i need to check, i'm wondering if there is a way to accomplish this in more efficient manner?  Is it possible to create a loop to go though a list of fields?

 

Thanks.

Hello.  

 

I'm trying to modify to code from force.com cookbook, found here,  to render the page detail or related list, based on the user selection of the drop-down field.   I added the drop-down list, but not sure how to grab the selected value and render the outputPanels.   I'm new to VisualForce developement, any assistance is very much appreaciated.

 

My VF page:

<apex:page controller="contactController" showHeader="true" tabStyle="Contact">
<apex:form >

    <select id="selection">
      <option value="Detail">Detail</option>
      <option value="List">List</option>
    </select>

  
    <apex:dataTable value="{!contacts}" var="c" cellpadding="4" border="1">
      <apex:column >
        <apex:facet name="header"><b>Name</b></apex:facet>
        
        <apex:commandLink reRender="detail">{!c.name}
          <apex:param name="id" value="{!c.id}"/>
        </apex:commandLink>
      </apex:column>
      
      <apex:column >
        <apex:facet name="header"><b>Account Name</b></apex:facet>
        {!c.account.name}
      </apex:column>
    </apex:dataTable>
  </apex:form>
  
  <apex:outputPanel id="detail" >
    <apex:detail subject="{!contact}" title="false" relatedList="false"/>
  </apex:outputPanel>
  
  <apex:outputPanel id="list">
     <apex:relatedList list="ActivityHistories"  subject="{!contact}"/>
  </apex:outputPanel>  
  
</apex:page>

 Controller:

 

public class contactController {

   
   public List<Contact> getContacts() {
      return [SELECT Id, Name, Account.Name, Phone, Email
              FROM Contact
              ORDER BY LastModifiedDate DESC LIMIT 10];
   }

  
   public Contact getContact() {
      Id id = System.currentPageReference().getParameters().get('id');
      return id == null ? new Contact() : [SELECT Id, Name
                                             FROM Contact
                                            WHERE Id = :id];
   }
   
}