• Soozee
  • NEWBIE
  • 155 Points
  • Member since 2011

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 43
    Replies

I'm trying to create my first Visualforce email template that will be used in a workflow rule when a field is updated with a specific value.  

I feel like I'm pretty close, but I am getting the following error when trying to save the Email Template:

 

Error: <messaging:emailTemplate> cannot contain <apex:form>.

 

But, when I take the <apex:form> tags out, I get this error:

 

Error: c:travelregistry_email_template_component must occur between <apex:form></apex:form> tags

 

Here is the VisualForce Email Template code:

 

<messaging:emailTemplate subject="Travel Itinerary for : {!Relatedto.Trip_Name__c}"  recipientType="User" relatedToType="Travel_Registry__c">

<messaging:htmlEmailBody >

<p>Your itinerary for: {!relatedto.trip_name__c} is below.  <br />
<br /></p>

<c:TravelRegistry_Email_Template_Component TRID="{!RelatedTo.ID}"/>

</messaging:htmlEmailBody>

</messaging:emailTemplate>

 Here is the Component Code:

 

<apex:component controller="Travel_Itinerary_Print_Controller_Ext" access="global">
<apex:attribute name="TRID" type="ID" assignTo="{!TravelId}" description="Travel ID for the email template"/>


<c:TravelRegistry_Page_Header_For_Email />

   
        <table width="100%">           
            <tr>
                <td>
                    &nbsp;&nbsp;&nbsp;<font size="+1">Travel Itinerary for {!TripName}</font>
                    <apex:inputText id="TripId" value="{!TripId}" rendered="false"/>                                        
                </td>
            </tr>
            <tr>
                <td>    
                    <apex:messages />                                   
                </td>
            </tr>
        </table>
        <table width="100%">
            
            <tr>
                <td colspan="2">
                    <apex:dataTable value="{!AccommodationsList}" var="accommodations">  
                                        
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Location Name 
                                    </apex:facet>
                                    {!Accommodations.Nickname}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Accommodation Type 
                                    </apex:facet>
                                    {!Accommodations.AccommodationsType}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Start Date 
                                    </apex:facet>
                                    {!Accommodations.StartDate}                                                                       
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                         End Date 
                                    </apex:facet>
                                    {!Accommodations.EndDate}                                                                        
                                 </apex:column>
                                 
                           </apex:dataTable>                          
                  
                          <apex:dataTable value="{!FlightList}" var="flight">
                                                                     
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Airline 
                                    </apex:facet>
                                    {!flight.Airline}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Flight # 
                                    </apex:facet>
                                    {!flight.FlightNumber}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure Date 
                                    </apex:facet>
                                    {!flight.StartDate}                                                                 
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" > 
                                        Departure Airport
                                    </apex:facet>
                                    {!flight.DepartureAirportCode}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Arrival Airport
                                    </apex:facet>
                                    {!flight.ArrivalAirportCode}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Overnight?
                                    </apex:facet>
                                    {!flight.OvernightFlight}                                                                        
                                 </apex:column>
                                 
                           </apex:dataTable>                              
                          
                           <apex:dataTable value="{!OtherList}" var="other">
                                         
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Type 
                                    </apex:facet>
                                    {!other.RecordTypeName}                                                                        
                                 </apex:column>
                                 
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Carrier Name 
                                    </apex:facet>
                                    {!other.Nickname}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure City 
                                    </apex:facet>
                                    {!other.DepartureCity}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure Date 
                                    </apex:facet>
                                    {!other.StartDate}                                                                     
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                         Arrival City 
                                    </apex:facet>
                                   {!other.ArrivalCity}                                                                   
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" > 
                                        Arrival Date
                                    </apex:facet>
                                    {!other.EndDate}                                                                        
                                 </apex:column>
                           </apex:dataTable>
            </td>
           </tr>
        
        </table>
             

</apex:component>

 And, finally the Controller Code:

 

public without sharing class Travel_Itinerary_Print_Controller_Ext {
	
	Private string email;
	public Id TravelId {get;set;}
	public String TripId {get;set;}
	public String TripName {get;set;}
	public List<ItineraryWrapperDTO> AccommodationsList {get;set;}
	public List<ItineraryWrapperDTO> FlightList {get;set;}
	public List<ItineraryWrapperDTO> OtherList {get;set;}
	
	
	public class ItineraryWrapperDTO {
         private Travel_Itinerary__c itinerarySf;
         
         public ItineraryWrapperDTO (Travel_Itinerary__c itSfObj) {
         	this.itinerarySf = itSfObj; 
         }    	
    	 public String Nickname {
    		get{if(itinerarySf != null){
	    			if(itinerarySf.Nickname__c != null){
	    				return itinerarySf.Nickname__c;
	    			}else{return ' ';}
    			}else{return null;}
    		}
    	 }
    	 public String Id {
    		get{return (itinerarySf != null) ? itinerarySf.Id : null;}
    	 }     	 
    	 public String AccommodationsType {
    		get{return (itinerarySf != null) ? itinerarySf.Accommodations_Type__c : null;}
    	 }
    	 public String Airline {
    		get{if(itinerarySf != null){
	    			 if(itinerarySf.Airline__c != null){
	    			 	return itinerarySf.Airline__c;}
	    			 else{return '';}
    			}else{return null;}}
    	 }
    	 public String RecordTypeName {
    		get{return (itinerarySf != null) ? itinerarySf.RecordType.DeveloperName : null;}
    	 }
    	 
    	 public String ArrivalAirportCode {
    		get{return (itinerarySf != null) ? itinerarySf.Arrival_Airport_Code__c : null;}
    	 }
    	 public String ArrivalCity {
    		get{return (itinerarySf != null) ? itinerarySf.Arrival_City__c : null;}
    	 }
    	 public String City {
    		get{return (itinerarySf != null) ? itinerarySf.City__c : null;}
    	 }
    	 public String Country{
    		get{return (itinerarySf != null) ? itinerarySf.Country__c : null;}
    	 }
    	 public String DepartureAirportCode {
    		get{return (itinerarySf != null) ? itinerarySf.Departure_Airport_Code__c : null;}
         }
    	 public String DepartureCity {
    		get{return (itinerarySf != null) ? itinerarySf.Departure_City__c : null;}
    	 }
    	 public String EndDate {
    		get{return (itinerarySf != null && itinerarySF.End_Date__c != null) ? itinerarySf.End_Date__c.format() : null;}
    	 }
    	 public String FlightNumber {
    		get{return (itinerarySf != null) ? itinerarySf.Flight_Number__c : null;}
    	 }
    	 public String MobilePhone {
    		get{return (itinerarySf != null) ? itinerarySf.Mobile_Phone__c : null;}
    	 }
    	 public String OvernightFlight {
    		get{if(itinerarySf != null){
	    			if(itinerarySf.OverNight_Flight__c == true){
	    				return 'Yes';
	    			}else{
	    				return 'No';
	    			}
    			}else{return null;}
    		}    		
    	 }
    	 public String PostalCode {
    		get{return (itinerarySf != null) ? itinerarySf.Postal_Code__c : null;}
    	 }
    	 public String PrimaryPhone {
    		get{return (itinerarySf != null) ? itinerarySf.Primary_Phone__c : null;}
    	 }
    	 public String StartDate {
    		get{return (itinerarySf != null && itinerarySf.Start_Date__c != null) ? itinerarySf.Start_Date__c.format() : null;}
    	 }
    	 public boolean getReadOnly() {
    		return (itinerarySf != null) ? itinerarySf.Read_Only__c : null;
    	 }
    	 public String WorkPhone {
    		get{return (itinerarySf != null) ? itinerarySf.Work_Phone__c : null;}
    	 }
	}

	public Travel_Itinerary_Print_Controller_Ext(){
		Map<Id,Travel_Itinerary__c> studentItineraryMap = new Map<Id,Travel_Itinerary__c>();
			
		FlightList = new List<ItineraryWrapperDTO>();
		OtherList = new List<ItineraryWrapperDTO>();
		AccommodationsList = new List<ItineraryWrapperDTO>();
			
	if (travelId!=null){
				
			Travel_Registry__c thisTrip = [SELECT Id, recordType.Name, person_travelling__r.Id, person_travelling__r.name, Trip_Name__c from Travel_Registry__c where Id = :travelId limit 1];
			if(thisTrip.Trip_Name__c != null){
				TripName = thisTrip.Trip_Name__c;					
			}			
			
			List<Travel_Itinerary__c> StudentItinerary = [SELECT Id, Overnight_Flight__c, RecordType.DeveloperName, Accommodations_Type__c, Airline__c, Arrival_Airport_Code__c, Arrival_Airport_Code_Lookup__c, Arrival_City__c, City__c, Country__c, Departure_Airport_Code__c, Departure_Airport_Code_Lookup__c, Departure_City__c, Display_Name__c, Edited_By_Student__c, End_Date__c, Flight_Number__c, Mobile_Phone__c, Nickname__c, Personal_Travel__c, Postal_Code__c, Primary_Phone__c, Read_Only__c, Start_Date__c, State_Province__c, Status__c, Street_1__c, Street_2__c, Street_3__c, Work_Phone__c, travel_registry__r.travel_type__c FROM Travel_Itinerary__c where travel_registry__r.Id = :travelId];
			if(StudentItinerary.size()>0){
				for(Travel_Itinerary__c si : StudentItinerary){
					studentItineraryMap.put(si.Id,si);
					
					if(si.RecordType.DeveloperName == 'Flight'){
							FlightList.add(new ItineraryWrapperDTO(si));
					}else if(si.RecordType.DeveloperName == 'Rail' || si.RecordType.DeveloperName == 'Boat' || si.RecordType.DeveloperName == 'Bus' || si.RecordType.DeveloperName == 'Car' || si.RecordType.DeveloperName == 'Other'){
							OtherList.add(new ItineraryWrapperDTO(si));
					}else if(si.RecordType.DeveloperName == 'Accommodations'){
							AccommodationsList.add(new ItineraryWrapperDTO(si));
					}
				}
			}
		}
	}
}

 Any help or guidance you can give me is greatly appreciated!

 

  • December 03, 2013
  • Like
  • 0

Hello,

I have VF page with several links.  When you click on a link, a 'pop up' window opens.  The pop up window is actually an outputpanel that gets rendered when you click on the link.

I am having trouble with the Save button on the 'pop up'.

The save button calls some javascript which calls an action function which calls some apex.

But, the apex never gets called...

Here is the code.

VF Page where commandButton calls JS saveletteredits();

<apex:pageBlockButtons >              
                <apex:commandButton value="Save" title="Save changes" onClick="saveLetterEdits(); return false;"/>
                <apex:commandButton action="{!cancel}" value="Cancel" title="Cancel changes"/>
                <apex:commandButton action="{!reset}" value="Reset to Default Text" title="Reset to default text"/>
                <apex:actionStatus startText="(Saving...)" stopText=""/>
            </apex:pageBlockButtons>

 JS on VF Page:

<script type="text/javascript">
            var TextAreaID = document.getElementById("{!$Component.LetterTxtArea}");
            
            CKEDITOR.replace( TextAreaID, {
            toolbar :   [
                { name: 'styles', items : ['Font','FontSize', 'TextColor' ] },
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','JustifyLeft','JustifyCenter','JustifyRight' ] }
                
            ]});
            CKEDITOR.config.width ='95%';
            CKEDITOR.config.height='350px';
             
            
            function saveLetterEdits(){         
            	
            	var _txtAreaID = $('.bodyTextArea').attr('id');
            	var _txtAreaEditor = CKEDITOR.instances[_txtAreaID];
            	var _oldText = _txtAreaEditor.getData();
            	document.getElementById('{!$Component.myHtmlField}').value = _oldText;
            	
            	//alert(ltrsubj);
            	passTheString();
            	//alert('passed the string');
            	
            	
            }
            
            
            </script>

 

VF page Action Function:

  <apex:actionFunction name="passTheString" action="{!saveTheLetter}" rerender="ltrbdypanel,textPanel"/>

 

Apex Class:

public PageReference saveTheLetter() { 
    	string newsubject = string.valueof(mysubject);
    	string newHTML = string.valueof(myHTML);
    	//displayPopup = false;
    	//system.debug('save letter');
    	Id letterID = System.currentPageReference().getParameters().get('ltrbdyID');
    	system.debug('saving letter '+letterID);
    	//system.debug('subject '+thesubject);
    	Letter__c l = [SELECT letter_template_name__c, reviewed__c, letter_uid__c, status__c, attention__c, letter_body__c FROM letter__c WHERE id = :letterID];
		l.status__c = 'Reviewed';
		l.attention__c = false; 
		l.reviewed__c = true; 
		l.letter_body__c = newHTML;
		l.Subject_Edited__c = newsubject;
		//l.Letter_Type_Edited__c = newlettertype;
		l.Letter_Template_Name_Edited__c = TplType;
		update l;
    //Pagereference s = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    //return s; 
    	
    	return null;

  }

 

I've been tweaking things here and there to get this to work...

Any help is greatly appreciated!!!!

 

 

  • January 10, 2013
  • Like
  • 0

Hi - I have a drop down on a VF page that displays the number of pages of records.

I want to be able to programmatically set the drop down value to '1' when the user sorts by any column header.

I know this should be pretty simple, but I've been searching for an answer and cannot find anything.....

Here's the VF code for populating the drop down with data from the controller

 

<apex:selectList id="pgnm" size="1" value="{!pagenum}" onChange="changePage(this.options[this.selectedIndex].text);">
             	<apex:selectOptions value="{!pageNumbers}"/>
                </apex:selectList>
                <br/>
                <apex:actionFunction name="changePage" action="{!goToPage}" rerender="out" status="loading">
     				<apex:param assignTo="{!pagenum}" value="" name="pagenum"/>
   				</apex:actionFunction>

 

Here's the code that I want to cause the reset of the drop down to '1':

<apex:facet name="header" >
                    <apex:outputLink onclick="SortByStuLastName();return false;">Student Name</apex:outputLink>
                </apex:facet>

 I've tried adding a javascript function after the return false;  and calling it like this:setPageNum(' {!$Component.ltrowner}') but this did not work...

function setPageNum(val){
		document.getElementById(val).value = '1';
  }

 Your help is greatly appreciated!

  • August 30, 2012
  • Like
  • 0

Hi, I have an Apex class that creates a PDF attachment for each id that it is passed.

This works great when only 50 or so IDs are passed in, but any more than that and I get a Heap error.

 

I read somewhere that I could create a webservice in Apex to get around this, but I can't find any documentation about calling a salesforce webservice from within the same salesforce org.

 

If anyone can point me in the right direction, or suggest a different solution, that would be greatly appreciated!

  • August 27, 2012
  • Like
  • 0

Hello,

I am creating a large PDF document from my Apex controller.  From the controller , I am sending over 400 record IDs.

So, the URL that is returned from the controller looks like this:

apex/myPage?id=a16V00000GVC4IAO%2C..... plus 400 or so more IDs.

 

When I run the code with fewer IDs, it works.

When I run with over 400 IDs, I get a Heap error.

I can't view any more info about the error, because the Developer Console crashes every time.

 

Is there a limit to how many IDs I can send to a page using the method above?

Any help would be greatly appreciated!

Thank you in advance!

  • August 22, 2012
  • Like
  • 0

I am trying to pass the value of a string that is held in a variable inside a javascript function on the visualforce page to the controller.

All that ever gets passed is null.  Hoping someone can help me?

 

(I am trying to implement an external rich text editor b/c our customer needs the font/color/size options which are not available in native salesforce wysiwyg editor).

 

Here is the code:

 

<apex:pageBlock mode="edit">
            <apex:pageBlockButtons >
               
              <apex:commandButton value="Save" title="Save changes" onClick="saveChanges()"/>          
                <apex:commandButton action="{!cancel}" value="Cancel" title="Cancel changes"/>
                <apex:commandButton action="{!reset}" value="Reset to Default Text" title="Reset to default text"/>
                <apex:actionStatus startText="(Saving...)" stopText=""/>
            </apex:pageBlockButtons>
             <apex:outputfield value="{!Letter__c.Letter_Body_Default__c}" rendered="false"/>
             <apex:outputfield value="{!Letter__c.Letter_UID__c}" rendered="false"/>
            
			           
            <apex:inputtextarea rows="60" cols="150" rendered="true" richtext="false" id="LetterTxtArea" value="{!Letter__c.Letter_Body__c}"/>
            

  
            <script type="text/javascript">
             
            var myTextBox;
            var TextAreaID = document.getElementById("{!$Component.LetterTxtArea}");
			var toolbar_1 = ["separator","undo","redo","separator","bold","italic","underline","separator","left","right","center","justify"];
			var toolbar_2 = ["separator","fontfamily","fontsize","fontcolor","separator","ol","ul","separator","indent","outdent","separator","hyperlink"];
			var toolbar_3 = ["separator","undo","redo","separator","bold","italic","underline","separator","left","right","center","justify","separator","fontfamily","fontsize","fontcolor","separator","ol","ul","separator","indent","outdent","separator","hyperlink"];
			
			$(document).ready(function(){
			//alert('swapping now');
			myTextBox =	$(TextAreaID).htmlbox({
					toolbars:[toolbar_3],
					idir:"{!URLFOR($Resource.HTMLBox, 'images')}",
					about:false
				});
			});
			
			function saveChanges(){
				var strHtml = myTextBox.get_html();
				alert(strHtml);
				Save(strHtml);
			}
			</script>
        
 </apex:pageBlock>
    
    

 The alert pops up with the value of the text box, including all of the html tags.

 

public class EndOfTermControllerExtension {
   
    private id letterID;
    private Letter__c letter;
  
    public String textBox{
    	get;
    	set{
    		textBox = value;
    		system.debug('value: '+value);	
    	}
    }
     
    
    Apexpages.StandardController controller;
    public EndOfTermControllerExtension(ApexPages.StandardController stdcontroller) {
        letter = (Letter__c)stdController.getRecord();
        letterID = letter.id;       
        controller = stdController;
 
  }

		
 
     
    public void doReset(){
        letter.letter_body__c = letter.letter_body_default__c;
    }   
    


   public PageReference saveletter() { // overwrite standard Save method
      //string text = string.valueof(lettertext);
      	//String lettertext = ApexPages.CurrentPage().getParameters().get('textBox');  
    	System.debug('textBox is '+textBox);
    	Letter__c l = [SELECT reviewed__c, letter_uid__c, status__c, attention__c, letter_body__c FROM letter__c WHERE id = :letterID];
		l.status__c = 'Reviewed';
		l.attention__c = false; 
		l.reviewed__c = true; 
		l.letter_body__c = textBox;
		update l;

      
      Pagereference s = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    return s; 
    //return null;
  }
  
  public PageReference cancel() { // overwrite standard Cancel method
      controller.cancel(); //invoke standard Cancel method
      Pagereference c = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    return c;    
  }
  
  public PageReference reset() { 
      doReset();  
    return Apexpages.currentPage(); //refresh current page      
  }

 All that ever gets passed to the controller is null.

 

Can someone help?  I feel like I am SO close!!!

 

Thanks!!!

Hi - I created a changeset 10 days ago and uploaded and deployed perfectly.

I have since made changes to some of the classes in that changeset and want to redeploy.

 

Do I have to create a new changeset, or can I re-upload and deploy that already created one?

(I asked because I tried the latter and the changes didn't appear)

 

Thanks,

Suzie

I have a page that does a dynamic update.  This update takes 4 seconds, so I thought it would be super cool to implement the jQuery blockUI to block the page to let the user know that something is happening behind the scenes.  Here's my code that I cannot get to work.

 

<apex:page controller="EndOfTermController"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/> 
<apex:includeScript value="{!URLFOR($Resource.jquery, 'js/jquery.blockUI.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery, 'js/jquery.jquery-ui-1.8.20.custom.min.js')}"/>
<apex:form > 
   <apex:actionFunction name="SupressLetter" action="{!suppressLetter}" rerender="out" status="loading">
     <apex:param name="firstparam" assignto="{!selSupLetterID}" value="" /> 
   </apex:actionFunction>
   <apex:actionStatus id="loading" onstart="loading(true)" onstop="loading(false)" />
 
       
  
  <div class="contentLoaded">  
 
  <!-- LOTS OF PAGE CONTENT  HERE -->

  </div>
</form>
</apex:page>


 Here is the script on the page:

 

<script type="text/javascript">
  var j$ = jQuery.noConflict();
  var val;
  
  function loading(val) {
  
    if (val) {    
      alert("Hello! I am an alert box!!"+ val);
      j$('.contentLoaded').blockUI();
      //j$('div.contentLoaded').block({ message: null });
      //document.getElementById('contentLoading').style.display = 'block';
      //document.getElementById('contentLoaded').style.display = 'none';
    }
    else {
      
      alert("Hello! I'm the else!!" +val);
      j$('.contentLoaded').unblockUI();
      //j$('div.contentLoaded').unblock({ message: null});
      //document.getElementById('contentLoading').style.display = 'none';
      //document.getElementById('contentLoaded').style.display = 'block';
    }
  }
</script>

Has anyone successfully used the blockUI function to work on a visualforce page?

 

Thanks,

Suzie

I need to be able to convert the values in a set into a comma separated list so that I can use it in a SOQL query.

Here is the code:

 

        List<GroupMember> getGroups = [SELECT group.name FROM GroupMember WHERE UserOrGroupId =:someID];
        system.debug('after getGroups' +getGroups);

	for (integer i=0;i<getGroups.size();i++){	
			system.debug('Group Name ='+getGroups[i].group.name);
			if (OTHERCLASS.MAP_BY_GROUPNAME.containsKey(getGroups[i].group.name)==true){
				collegeList.add(OTHERCLASS.MAP_BY_GROUPNAME.get(getGroups[i].group.name));				
			}
        }
        system.debug('college list after adding to set'+collegeList);
        // add all to array
        //CollegeListArr.addAll(collegeList);  // this does not work
        system.debug('after adding to array');
        for(integer y=0;y<collegeList.size();y++){
        if(y>0) collegeListArr +=',';  
        collegeListArr += collegeList[y].id; // this does not work
        }
 

If I try to addall, I get an error on the Visual Force page:  unexpected token: '{College Name}'  

If I try the second method, I get 'Illegal Assignment from String to Set<String>'

 

Help?!?!

I want to render a button based on a user's public group membership.

For example, if user is member of Email Administrator public group, they should be able to see an 'Email Button' at the bottom of the page.

 

Here is the VF Page:

 

<apex:form>
... lots of other stuff...

<apex:commandButton value="Email Letters" onclick="if (confirmation()) addEmailLettersJS(); return false;" rendered="{!renderButton}"/>
</apex:form>

 Here is the controller:

 

public boolean renderButton() {
    
    System.DEBUG('********* renderButton');
       List<GroupMember> getGroup = [SELECT UserOrGroupId FROM GroupMember WHERE UserOrGroupId =:advid and group.name = 'EOTL - Email Admin'];
       //GroupMember[] getGroup=[SELECT UserOrGroupId FROM GroupMember WHERE UserOrGroupId =:advid and group.name = 'EOTL - Email Admin'];

        if (getGroup[0].UserOrGroupId == advID){
            showButton=true;
        }else{
            showButton=false;
        }
        System.DEBUG('********* value of show button = '+showButton);
      return showButton;
    }

 

The {!renderButton} on the page ALWAYS returns false, even when the user is in the group.

Also, the debug never writes the console.

 

Help!?!

  • April 25, 2012
  • Like
  • 0

Hi - I want to dynamically update a record when a user clicks a checkbox on my vf page, but I cannot figure out how to pass the record id of the row that is clicked to the Controller.

 

 

 

 

 

  • April 17, 2012
  • Like
  • 0
trigger Trigger_Name on CustomObject__c (after insert) {
List<CustomObject__c> emailList = [select id from CustomObject__c where ID in :trigger.newMap.keyset()];
List<OtherCustomObject__c> recordsToUpdate = new List<OtherCustomObject__c>{};

for(CustomObject__c e: emailList){

for(OtherCustomObject__c le : e.letter__r.id ){
le.emailed__c=true;
le.date_emailed__c = datetime.now();
lettersToUpdate.add(le);
} 

update lettersToUpdate; 
}
}

Hello - I would like to update a field in one object based on the creation of a record in aother object.

 

I get this error when I try to save:  

Save error: Loop must iterate over a collection type: Id 

 

Help?

 

  • March 29, 2012
  • Like
  • 0

Hello,

I am trying to extract a list of ids from a SOQL query as a comma separated string so that I can then pass the string to another method which will create a PDF of the records.  The results should look like this:  X2VV0000000DxXxxxx,X2VV0000000DxXxXXX,X2VV0000000XxXtXXX

 

Since result.getParameters().put() is expecting two strings, the Apex won't compile.  I get:  Save error: Incompatible value type LIST<Letter__c> for MAP<String,String>   


Here is the code:

 

    public PageReference generateBatchPDF() {
    	
    	
        String letterIDs = ApexPages.CurrentPage().getParameters().get('letterIDs');
        System.Debug('DEBUG: String letterIDs = '+letterIDs);
       
        String[] listofids = letterIds.split(',');
        List<Letter__c> printletters = [select id from Letter__c where format__c != 'email only' and id IN :listofids];
        
        System.Debug('DEBUG: List printletters = '+printletters);
        
        PageReference result=new PageReference('/apex/EOTLBatchPDF');
        
        result.getParameters().put('id', printletters);
       
        return result;
    }

 

  • March 12, 2012
  • Like
  • 0

Hello,

In my visualforce page, I have a 'reset to default' button.

When the user clicks on this button, I want richtextfield1__c field to be rewritten with richtextfield2__c.

 

How do I do this?

 

 

  • March 01, 2012
  • Like
  • 0

Hi - Where should I look to view the standard salesforce stylesheet?  I want to see if I can use styles already created before I create a custom stylesheet.

 

Thanks!

  • February 29, 2012
  • Like
  • 0

Several people have asked this question, and I have tried all of the solutions, but nothing has worked.

 

I want to be able to pass the name of the column header that was clicked on the page into the controller so that I can determine which way to sort (asc vs. desc).

 

Here is my VF page:

<apex:actionFunction name="SortByID" action="{!sortbyRecordID}" rerender="out"/>   

<apex:outputPanel id="out">
<apex:pageBlock >
<apex:pageBlockTable value="{!studentListLongArr}" var="enrollment" rendered="{!EnrollmentListSize > 0}">
<apex:column >
<apex:pageBlockTable value="{!enrollment.Registered_Student__r}" var="stulist">

<apex:column >
<apex:facet name="header">
<apex:commandLink onclick="SortByID();return false;" action="{!doSort}" rerender="out">Record ID
<apex:param name="sortField" value="recordid"/>
</apex:commandLink>
</apex:facet>
<apex:outputLink value="/{!stulist.id}" target="_top">{!stulist.Name}</apex:outputLink>
</apex:column>

 

Here is my controller:

public String direction {get; set;}
public String sortField {public get; public set;}
public String previousSortField {get; set;}

public void doSort(){
direction = 'asc';
//This checks to see if the same header was clicked twice in a row, if so
//it switches the order.
if(previousSortField == sortField){
direction = 'desc';
previousSortField = null;
}else{
previousSortField = sortField;
}
}

public PageReference sortbyRecordID(){

doSort();
System.debug('Value of sortfield is: '+ sortField);
String SOQLQuery1 = 'SELECT id, (Select E.Student_Athlete__c, E.Case__c, E.Number_of_Cases__c, E.Enrollment_Status__c, E.Date_of_Withdrawal__c, E.student__r.name, E.Name, E.Final_Grade__c from Registered_Student__r E LIMIT 5) FROM Course__c where id = :courseId order by id '+ direction;
studentListArr = database.query(SOQLQuery1 );
System.debug('SQL Query1 is :' + SOQLQuery1 );
String SOQLQuery2 = 'SELECT id, (Select E.Student_Athlete__c, E.Case__c, E.Number_of_Cases__c, E.Enrollment_Status__c, E.Date_of_Withdrawal__c, E.student__r.name, E.Name, E.Final_Grade__c from Registered_Student__r E) FROM Course__c where id = :courseId order by id '+ direction;
studentListLongArr = database.query(SOQLQuery2 );
return null;
}

 

 

 

  • November 23, 2011
  • Like
  • 0

Hello,

I am trying to use a variable in the order by clause of a SOQL statement, like this:

 

enrollmentLongArr = [select E.Id, E.Name, E.Course__c, E.Course__r.Name, E.Case__c, E.Repeat_Class__c, E.Number_Of_Cases__c, E.Enrollment_Status__c, E.Date_of_Withdrawal__c, E.CreatedDate, E.Final_Grade__c from Enrollment__c E where E.Student__c = :accountId order by E.Course__r.Name :direction ];

 

where :direction will either be asc or desc.

 

I keep getting an error when I try to save my class:

save error: unexpected token ':'

 

What am I doing wrong?

  • November 21, 2011
  • Like
  • 0

I'm trying to create my first Visualforce email template that will be used in a workflow rule when a field is updated with a specific value.  

I feel like I'm pretty close, but I am getting the following error when trying to save the Email Template:

 

Error: <messaging:emailTemplate> cannot contain <apex:form>.

 

But, when I take the <apex:form> tags out, I get this error:

 

Error: c:travelregistry_email_template_component must occur between <apex:form></apex:form> tags

 

Here is the VisualForce Email Template code:

 

<messaging:emailTemplate subject="Travel Itinerary for : {!Relatedto.Trip_Name__c}"  recipientType="User" relatedToType="Travel_Registry__c">

<messaging:htmlEmailBody >

<p>Your itinerary for: {!relatedto.trip_name__c} is below.  <br />
<br /></p>

<c:TravelRegistry_Email_Template_Component TRID="{!RelatedTo.ID}"/>

</messaging:htmlEmailBody>

</messaging:emailTemplate>

 Here is the Component Code:

 

<apex:component controller="Travel_Itinerary_Print_Controller_Ext" access="global">
<apex:attribute name="TRID" type="ID" assignTo="{!TravelId}" description="Travel ID for the email template"/>


<c:TravelRegistry_Page_Header_For_Email />

   
        <table width="100%">           
            <tr>
                <td>
                    &nbsp;&nbsp;&nbsp;<font size="+1">Travel Itinerary for {!TripName}</font>
                    <apex:inputText id="TripId" value="{!TripId}" rendered="false"/>                                        
                </td>
            </tr>
            <tr>
                <td>    
                    <apex:messages />                                   
                </td>
            </tr>
        </table>
        <table width="100%">
            
            <tr>
                <td colspan="2">
                    <apex:dataTable value="{!AccommodationsList}" var="accommodations">  
                                        
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Location Name 
                                    </apex:facet>
                                    {!Accommodations.Nickname}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Accommodation Type 
                                    </apex:facet>
                                    {!Accommodations.AccommodationsType}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Start Date 
                                    </apex:facet>
                                    {!Accommodations.StartDate}                                                                       
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                         End Date 
                                    </apex:facet>
                                    {!Accommodations.EndDate}                                                                        
                                 </apex:column>
                                 
                           </apex:dataTable>                          
                  
                          <apex:dataTable value="{!FlightList}" var="flight">
                                                                     
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Airline 
                                    </apex:facet>
                                    {!flight.Airline}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Flight # 
                                    </apex:facet>
                                    {!flight.FlightNumber}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure Date 
                                    </apex:facet>
                                    {!flight.StartDate}                                                                 
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" > 
                                        Departure Airport
                                    </apex:facet>
                                    {!flight.DepartureAirportCode}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Arrival Airport
                                    </apex:facet>
                                    {!flight.ArrivalAirportCode}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Overnight?
                                    </apex:facet>
                                    {!flight.OvernightFlight}                                                                        
                                 </apex:column>
                                 
                           </apex:dataTable>                              
                          
                           <apex:dataTable value="{!OtherList}" var="other">
                                         
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Type 
                                    </apex:facet>
                                    {!other.RecordTypeName}                                                                        
                                 </apex:column>
                                 
                                 <apex:column >     
                                    <apex:facet name="header" >
                                        Carrier Name 
                                    </apex:facet>
                                    {!other.Nickname}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure City 
                                    </apex:facet>
                                    {!other.DepartureCity}                                                                        
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                        Departure Date 
                                    </apex:facet>
                                    {!other.StartDate}                                                                     
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" >
                                         Arrival City 
                                    </apex:facet>
                                   {!other.ArrivalCity}                                                                   
                                 </apex:column>
                                 <apex:column >    
                                    <apex:facet name="header" > 
                                        Arrival Date
                                    </apex:facet>
                                    {!other.EndDate}                                                                        
                                 </apex:column>
                           </apex:dataTable>
            </td>
           </tr>
        
        </table>
             

</apex:component>

 And, finally the Controller Code:

 

public without sharing class Travel_Itinerary_Print_Controller_Ext {
	
	Private string email;
	public Id TravelId {get;set;}
	public String TripId {get;set;}
	public String TripName {get;set;}
	public List<ItineraryWrapperDTO> AccommodationsList {get;set;}
	public List<ItineraryWrapperDTO> FlightList {get;set;}
	public List<ItineraryWrapperDTO> OtherList {get;set;}
	
	
	public class ItineraryWrapperDTO {
         private Travel_Itinerary__c itinerarySf;
         
         public ItineraryWrapperDTO (Travel_Itinerary__c itSfObj) {
         	this.itinerarySf = itSfObj; 
         }    	
    	 public String Nickname {
    		get{if(itinerarySf != null){
	    			if(itinerarySf.Nickname__c != null){
	    				return itinerarySf.Nickname__c;
	    			}else{return ' ';}
    			}else{return null;}
    		}
    	 }
    	 public String Id {
    		get{return (itinerarySf != null) ? itinerarySf.Id : null;}
    	 }     	 
    	 public String AccommodationsType {
    		get{return (itinerarySf != null) ? itinerarySf.Accommodations_Type__c : null;}
    	 }
    	 public String Airline {
    		get{if(itinerarySf != null){
	    			 if(itinerarySf.Airline__c != null){
	    			 	return itinerarySf.Airline__c;}
	    			 else{return '';}
    			}else{return null;}}
    	 }
    	 public String RecordTypeName {
    		get{return (itinerarySf != null) ? itinerarySf.RecordType.DeveloperName : null;}
    	 }
    	 
    	 public String ArrivalAirportCode {
    		get{return (itinerarySf != null) ? itinerarySf.Arrival_Airport_Code__c : null;}
    	 }
    	 public String ArrivalCity {
    		get{return (itinerarySf != null) ? itinerarySf.Arrival_City__c : null;}
    	 }
    	 public String City {
    		get{return (itinerarySf != null) ? itinerarySf.City__c : null;}
    	 }
    	 public String Country{
    		get{return (itinerarySf != null) ? itinerarySf.Country__c : null;}
    	 }
    	 public String DepartureAirportCode {
    		get{return (itinerarySf != null) ? itinerarySf.Departure_Airport_Code__c : null;}
         }
    	 public String DepartureCity {
    		get{return (itinerarySf != null) ? itinerarySf.Departure_City__c : null;}
    	 }
    	 public String EndDate {
    		get{return (itinerarySf != null && itinerarySF.End_Date__c != null) ? itinerarySf.End_Date__c.format() : null;}
    	 }
    	 public String FlightNumber {
    		get{return (itinerarySf != null) ? itinerarySf.Flight_Number__c : null;}
    	 }
    	 public String MobilePhone {
    		get{return (itinerarySf != null) ? itinerarySf.Mobile_Phone__c : null;}
    	 }
    	 public String OvernightFlight {
    		get{if(itinerarySf != null){
	    			if(itinerarySf.OverNight_Flight__c == true){
	    				return 'Yes';
	    			}else{
	    				return 'No';
	    			}
    			}else{return null;}
    		}    		
    	 }
    	 public String PostalCode {
    		get{return (itinerarySf != null) ? itinerarySf.Postal_Code__c : null;}
    	 }
    	 public String PrimaryPhone {
    		get{return (itinerarySf != null) ? itinerarySf.Primary_Phone__c : null;}
    	 }
    	 public String StartDate {
    		get{return (itinerarySf != null && itinerarySf.Start_Date__c != null) ? itinerarySf.Start_Date__c.format() : null;}
    	 }
    	 public boolean getReadOnly() {
    		return (itinerarySf != null) ? itinerarySf.Read_Only__c : null;
    	 }
    	 public String WorkPhone {
    		get{return (itinerarySf != null) ? itinerarySf.Work_Phone__c : null;}
    	 }
	}

	public Travel_Itinerary_Print_Controller_Ext(){
		Map<Id,Travel_Itinerary__c> studentItineraryMap = new Map<Id,Travel_Itinerary__c>();
			
		FlightList = new List<ItineraryWrapperDTO>();
		OtherList = new List<ItineraryWrapperDTO>();
		AccommodationsList = new List<ItineraryWrapperDTO>();
			
	if (travelId!=null){
				
			Travel_Registry__c thisTrip = [SELECT Id, recordType.Name, person_travelling__r.Id, person_travelling__r.name, Trip_Name__c from Travel_Registry__c where Id = :travelId limit 1];
			if(thisTrip.Trip_Name__c != null){
				TripName = thisTrip.Trip_Name__c;					
			}			
			
			List<Travel_Itinerary__c> StudentItinerary = [SELECT Id, Overnight_Flight__c, RecordType.DeveloperName, Accommodations_Type__c, Airline__c, Arrival_Airport_Code__c, Arrival_Airport_Code_Lookup__c, Arrival_City__c, City__c, Country__c, Departure_Airport_Code__c, Departure_Airport_Code_Lookup__c, Departure_City__c, Display_Name__c, Edited_By_Student__c, End_Date__c, Flight_Number__c, Mobile_Phone__c, Nickname__c, Personal_Travel__c, Postal_Code__c, Primary_Phone__c, Read_Only__c, Start_Date__c, State_Province__c, Status__c, Street_1__c, Street_2__c, Street_3__c, Work_Phone__c, travel_registry__r.travel_type__c FROM Travel_Itinerary__c where travel_registry__r.Id = :travelId];
			if(StudentItinerary.size()>0){
				for(Travel_Itinerary__c si : StudentItinerary){
					studentItineraryMap.put(si.Id,si);
					
					if(si.RecordType.DeveloperName == 'Flight'){
							FlightList.add(new ItineraryWrapperDTO(si));
					}else if(si.RecordType.DeveloperName == 'Rail' || si.RecordType.DeveloperName == 'Boat' || si.RecordType.DeveloperName == 'Bus' || si.RecordType.DeveloperName == 'Car' || si.RecordType.DeveloperName == 'Other'){
							OtherList.add(new ItineraryWrapperDTO(si));
					}else if(si.RecordType.DeveloperName == 'Accommodations'){
							AccommodationsList.add(new ItineraryWrapperDTO(si));
					}
				}
			}
		}
	}
}

 Any help or guidance you can give me is greatly appreciated!

 

  • December 03, 2013
  • Like
  • 0

Hello,

I have VF page with several links.  When you click on a link, a 'pop up' window opens.  The pop up window is actually an outputpanel that gets rendered when you click on the link.

I am having trouble with the Save button on the 'pop up'.

The save button calls some javascript which calls an action function which calls some apex.

But, the apex never gets called...

Here is the code.

VF Page where commandButton calls JS saveletteredits();

<apex:pageBlockButtons >              
                <apex:commandButton value="Save" title="Save changes" onClick="saveLetterEdits(); return false;"/>
                <apex:commandButton action="{!cancel}" value="Cancel" title="Cancel changes"/>
                <apex:commandButton action="{!reset}" value="Reset to Default Text" title="Reset to default text"/>
                <apex:actionStatus startText="(Saving...)" stopText=""/>
            </apex:pageBlockButtons>

 JS on VF Page:

<script type="text/javascript">
            var TextAreaID = document.getElementById("{!$Component.LetterTxtArea}");
            
            CKEDITOR.replace( TextAreaID, {
            toolbar :   [
                { name: 'styles', items : ['Font','FontSize', 'TextColor' ] },
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','JustifyLeft','JustifyCenter','JustifyRight' ] }
                
            ]});
            CKEDITOR.config.width ='95%';
            CKEDITOR.config.height='350px';
             
            
            function saveLetterEdits(){         
            	
            	var _txtAreaID = $('.bodyTextArea').attr('id');
            	var _txtAreaEditor = CKEDITOR.instances[_txtAreaID];
            	var _oldText = _txtAreaEditor.getData();
            	document.getElementById('{!$Component.myHtmlField}').value = _oldText;
            	
            	//alert(ltrsubj);
            	passTheString();
            	//alert('passed the string');
            	
            	
            }
            
            
            </script>

 

VF page Action Function:

  <apex:actionFunction name="passTheString" action="{!saveTheLetter}" rerender="ltrbdypanel,textPanel"/>

 

Apex Class:

public PageReference saveTheLetter() { 
    	string newsubject = string.valueof(mysubject);
    	string newHTML = string.valueof(myHTML);
    	//displayPopup = false;
    	//system.debug('save letter');
    	Id letterID = System.currentPageReference().getParameters().get('ltrbdyID');
    	system.debug('saving letter '+letterID);
    	//system.debug('subject '+thesubject);
    	Letter__c l = [SELECT letter_template_name__c, reviewed__c, letter_uid__c, status__c, attention__c, letter_body__c FROM letter__c WHERE id = :letterID];
		l.status__c = 'Reviewed';
		l.attention__c = false; 
		l.reviewed__c = true; 
		l.letter_body__c = newHTML;
		l.Subject_Edited__c = newsubject;
		//l.Letter_Type_Edited__c = newlettertype;
		l.Letter_Template_Name_Edited__c = TplType;
		update l;
    //Pagereference s = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    //return s; 
    	
    	return null;

  }

 

I've been tweaking things here and there to get this to work...

Any help is greatly appreciated!!!!

 

 

  • January 10, 2013
  • Like
  • 0

Hi All,

 

Having a strange issue at the moment.

 

We have an APEX class updating a custom object, but it is failing with this error message:

 

INSUFFICIENT_ACCESS_OR_READONLY, user does not have access to use approval assignment email template: []

 

When the object is updated, a workflow email is sent as confirmation to the user. This is not a part of any approval process. In fact this object is not used in any approval process whatsoever.

 

We have already done plenty of experimenting and have discovered that if this workflow email is a VisualForce template containing any relatedto.FIELD , it fails with the above message. If it is any other email template type it works fine. 

 

We tried a basic VisualForce template as below, which doesn't cause the error:

 

<messaging:emailTemplate subject="test" recipientType="User" relatedToType="customobject__c">
<messaging:HtmlEmailBody >
test
</messaging:HtmlEmailBody>
</messaging:emailTemplate>

 

 

We then tried a VisualForce template with a field that works without error in the text based email..... but still it causes the above error in the visualforce template

 

<messaging:emailTemplate subject="test" recipientType="User" relatedToType="customobject__c">
<messaging:HtmlEmailBody >
test -  {!RelatedTo.Field__c}
</messaging:HtmlEmailBody>
</messaging:emailTemplate>

 

So there must be a problem with accessing the RelatedTo fields, I guess?

 

But why do the text based emails work?

 

 

 

 

 

 

  • November 10, 2012
  • Like
  • 0

Hi, I have an Apex class that creates a PDF attachment for each id that it is passed.

This works great when only 50 or so IDs are passed in, but any more than that and I get a Heap error.

 

I read somewhere that I could create a webservice in Apex to get around this, but I can't find any documentation about calling a salesforce webservice from within the same salesforce org.

 

If anyone can point me in the right direction, or suggest a different solution, that would be greatly appreciated!

  • August 27, 2012
  • Like
  • 0

I am trying to pass the value of a string that is held in a variable inside a javascript function on the visualforce page to the controller.

All that ever gets passed is null.  Hoping someone can help me?

 

(I am trying to implement an external rich text editor b/c our customer needs the font/color/size options which are not available in native salesforce wysiwyg editor).

 

Here is the code:

 

<apex:pageBlock mode="edit">
            <apex:pageBlockButtons >
               
              <apex:commandButton value="Save" title="Save changes" onClick="saveChanges()"/>          
                <apex:commandButton action="{!cancel}" value="Cancel" title="Cancel changes"/>
                <apex:commandButton action="{!reset}" value="Reset to Default Text" title="Reset to default text"/>
                <apex:actionStatus startText="(Saving...)" stopText=""/>
            </apex:pageBlockButtons>
             <apex:outputfield value="{!Letter__c.Letter_Body_Default__c}" rendered="false"/>
             <apex:outputfield value="{!Letter__c.Letter_UID__c}" rendered="false"/>
            
			           
            <apex:inputtextarea rows="60" cols="150" rendered="true" richtext="false" id="LetterTxtArea" value="{!Letter__c.Letter_Body__c}"/>
            

  
            <script type="text/javascript">
             
            var myTextBox;
            var TextAreaID = document.getElementById("{!$Component.LetterTxtArea}");
			var toolbar_1 = ["separator","undo","redo","separator","bold","italic","underline","separator","left","right","center","justify"];
			var toolbar_2 = ["separator","fontfamily","fontsize","fontcolor","separator","ol","ul","separator","indent","outdent","separator","hyperlink"];
			var toolbar_3 = ["separator","undo","redo","separator","bold","italic","underline","separator","left","right","center","justify","separator","fontfamily","fontsize","fontcolor","separator","ol","ul","separator","indent","outdent","separator","hyperlink"];
			
			$(document).ready(function(){
			//alert('swapping now');
			myTextBox =	$(TextAreaID).htmlbox({
					toolbars:[toolbar_3],
					idir:"{!URLFOR($Resource.HTMLBox, 'images')}",
					about:false
				});
			});
			
			function saveChanges(){
				var strHtml = myTextBox.get_html();
				alert(strHtml);
				Save(strHtml);
			}
			</script>
        
 </apex:pageBlock>
    
    

 The alert pops up with the value of the text box, including all of the html tags.

 

public class EndOfTermControllerExtension {
   
    private id letterID;
    private Letter__c letter;
  
    public String textBox{
    	get;
    	set{
    		textBox = value;
    		system.debug('value: '+value);	
    	}
    }
     
    
    Apexpages.StandardController controller;
    public EndOfTermControllerExtension(ApexPages.StandardController stdcontroller) {
        letter = (Letter__c)stdController.getRecord();
        letterID = letter.id;       
        controller = stdController;
 
  }

		
 
     
    public void doReset(){
        letter.letter_body__c = letter.letter_body_default__c;
    }   
    


   public PageReference saveletter() { // overwrite standard Save method
      //string text = string.valueof(lettertext);
      	//String lettertext = ApexPages.CurrentPage().getParameters().get('textBox');  
    	System.debug('textBox is '+textBox);
    	Letter__c l = [SELECT reviewed__c, letter_uid__c, status__c, attention__c, letter_body__c FROM letter__c WHERE id = :letterID];
		l.status__c = 'Reviewed';
		l.attention__c = false; 
		l.reviewed__c = true; 
		l.letter_body__c = textBox;
		update l;

      
      Pagereference s = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    return s; 
    //return null;
  }
  
  public PageReference cancel() { // overwrite standard Cancel method
      controller.cancel(); //invoke standard Cancel method
      Pagereference c = new PageReference('/apex/EOTL_CloseMePage');  // redirect to closer page
    return c;    
  }
  
  public PageReference reset() { 
      doReset();  
    return Apexpages.currentPage(); //refresh current page      
  }

 All that ever gets passed to the controller is null.

 

Can someone help?  I feel like I am SO close!!!

 

Thanks!!!

I have a page that does a dynamic update.  This update takes 4 seconds, so I thought it would be super cool to implement the jQuery blockUI to block the page to let the user know that something is happening behind the scenes.  Here's my code that I cannot get to work.

 

<apex:page controller="EndOfTermController"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/> 
<apex:includeScript value="{!URLFOR($Resource.jquery, 'js/jquery.blockUI.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery, 'js/jquery.jquery-ui-1.8.20.custom.min.js')}"/>
<apex:form > 
   <apex:actionFunction name="SupressLetter" action="{!suppressLetter}" rerender="out" status="loading">
     <apex:param name="firstparam" assignto="{!selSupLetterID}" value="" /> 
   </apex:actionFunction>
   <apex:actionStatus id="loading" onstart="loading(true)" onstop="loading(false)" />
 
       
  
  <div class="contentLoaded">  
 
  <!-- LOTS OF PAGE CONTENT  HERE -->

  </div>
</form>
</apex:page>


 Here is the script on the page:

 

<script type="text/javascript">
  var j$ = jQuery.noConflict();
  var val;
  
  function loading(val) {
  
    if (val) {    
      alert("Hello! I am an alert box!!"+ val);
      j$('.contentLoaded').blockUI();
      //j$('div.contentLoaded').block({ message: null });
      //document.getElementById('contentLoading').style.display = 'block';
      //document.getElementById('contentLoaded').style.display = 'none';
    }
    else {
      
      alert("Hello! I'm the else!!" +val);
      j$('.contentLoaded').unblockUI();
      //j$('div.contentLoaded').unblock({ message: null});
      //document.getElementById('contentLoading').style.display = 'none';
      //document.getElementById('contentLoaded').style.display = 'block';
    }
  }
</script>

Has anyone successfully used the blockUI function to work on a visualforce page?

 

Thanks,

Suzie

Hi - I want to dynamically update a record when a user clicks a checkbox on my vf page, but I cannot figure out how to pass the record id of the row that is clicked to the Controller.

 

 

 

 

 

  • April 17, 2012
  • Like
  • 0

Hi,

 

I have been struggling with this all day. I'm just trying to get the value that was selected in a SelectList, and use it to do some DML stuff. I don't need to do an ajax request and print back to the screen (that seems to be what all of the code snippets out there are doing).

 

Here's the VF page:

 

<apex:page controller="SelectPricebookController" action="{!pageLoad}" showHeader="false" sidebar="false" title="Select Price List">
    <div class="opportunityTab" style="margin:15px;">
        <apex:form id="TheForm">
        <apex:sectionHeader title="Opportunity" subtitle="Select Price List"/>
        <div class="bDescription"></div>
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Price Book" for="ddlPriceBooks"/>
                    <apex:selectList id="ddlPriceList" size="1" multiselect="false" value="{!priceList}" title="Select a Price List">
                    	<apex:selectOptions value="{!lists}"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Select" action="{!savePriceList}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock> 
        </apex:form>
    </div>
</apex:page>

 

 

and here's the controller:

 

public with sharing class SelectPricebookController {


    private Opportunity opp;
    private Account acc;
    private Boolean isDirect = true;
    private String[] optionsToAdd;

    public String pList;
    
    
    public String getPriceList() {
        return pList;
    }

   public void setPriceList(String p) {
       System.Debug('================================== Set priceList: ' + p);
        this.pList = p;
    }
    
    public PageReference pageLoad(){
        //Get the Opportunity based on the query param
        String OppID;
        if (ApexPages.currentPage().getParameters().get('OppID') != null){
            OppID = ApexPages.currentPage().getParameters().get('OppID');
            
            opp = [Select Purchase_Channel_Account__c, Name, AccountId, Price_List__c from Opportunity where ID = :OppID Limit 1];
            
            //Gets the correct account. If the Purchase Channel account is null,
            //it will get the primary account.
            //If not, it will get Purchase Channel Account
            if (opp.Purchase_Channel_Account__c != null){
                acc = [Select NAME, Available_Direct_Price_Lists__c, Available_Channel_Price_Lists__c from Account where ID = :opp.Purchase_Channel_Account__c  Limit 1];
                isDirect = false;
            }
            else{
                acc = [Select NAME, Available_Direct_Price_Lists__c, Available_Channel_Price_Lists__c from Account where ID = :opp.AccountId  Limit 1];
            }

            System.debug('Opportunity ID======================================================> ' + opp.id);
            System.debug('Accout ID======================================================> ' + acc.id);
            
            //Gets the available price lists from the account
            String[] lists;
        
            if(isDirect){
                lists = acc.Available_Direct_Price_Lists__c.split(';');
            }
            else{
                lists = acc.Available_Channel_Price_Lists__c.split(';');
            }
                        
            //If there is only one option, just update the opp and redirect
            //Else, show the user a list to pick from
            if(lists.size() == 1){
                optionsToAdd = lists;
                return updateOpp(lists[0]);
            }
            else{
                optionsToAdd = lists;
                return null;
            }
        }
        else{
            //TODO: Handle Exception
            return null;
        }
    }
    
    public List<SelectOption> getLists(){
        List<SelectOption> options = new List<SelectOption>();
        
        for (Integer i = 0; i < optionsToAdd.size(); i++){
            System.debug('Options======================================================> ' + optionsToAdd[i]);
            options.add(new SelectOption(optionsToAdd[i],optionsToAdd[i]));
        }
        
        return options;
    }
    
    public PageReference savePriceList(){
        System.debug('============== pricelist: ' + pList);
        return updateOpp(pList);
    }
    
    private PageReference updateOpp(String p){
        opp.Price_List__c = p;
        System.debug('====================== Updated pricelist to: ' + p);
        update opp;
        
        PageReference pageRef = new PageReference('/' + opp.Id);
        pageRef.setRedirect(true);
        return pageRef;
    }
}

 

 

As you can see, I have a public string variable to hold the value, a getter and a setter. Then I try to use the variable in the savePriceList method. However, it's always null.

 

Thanks for the help!

You've developed a VF page, but the richtext edit, while cool, needs more... I wish that SFDC would've given us a way to "sneak" a look at the HTML contents that form the construct of the message/text that we're editing. So you look behind the scenes with firebug or chrome, then you'll see that SFDC's WYSIWYG editor is just their slightly customized instance of the FCK editor.
 
 
 
The code block:
<apex:inputTextarea value="{!inputValue}" id="theTextarea" richText="true" />
  gets expanded behind the scenes into a few sections:
  1. a div that contains a hidden config value
  2. an iframe that contains the editor
  3. ...and javascript section that calls the necessary parameters when the page is loaded.
Hence, it is possible to embed a second call to the javascript that creates the FCK editor - merely doing this will result in two editors on the screen in Mozilla and IE (chrome won't display duplicate ID field objects...). That is a start, and with a little massaging, you can write a function to get rid of the existing iframe containing the old editor and replace it with the new editor that you're calling.
The steps to do this aren't too bad.
 
How to do it
  1. Create your visual force page as you see fit. It goes without saying that you should have a rich text block linked to some textarea field in your object.
  2. Once you've created your page, test it. Using Chrome or Firebug, find out the ids of the divs that get created when the page runs. From the above example, id="theTextarea", might get turned into:
    • The iFrame: "j_id0:j_id2:editBlock:j_id33:theTextarea___Frame"
    • The config block: "j_id0:j_id2:editBlock:j_id33:theTextarea___Config"
    • The textarea: "j_id0:j_id2:editBlock:j_id33:theTextarea"
      (Honestly, you're just interested in the prefix, the "j_id0:j_id2:editBlock:j_id33:" section - You can append the divId and "__Frame", etc...)
  3. Go back to your visualforce page and add this script block directly under the <apex:inputTextarea> code block.
    <script type="text/javascript">
     setTimeout("swap();",5000);
     function swap() {
      alert("Running function...");
     
      var origFrame = document.getElementById('j_id0:j_id2:editBlock:j_id33:theTextarea___Frame');
      alert("Removing iFrame");
      origFrame.parentNode.removeChild(origFrame);
    
      var configItem = document.getElementById('j_id0:j_id2:editBlock:j_id33:theTextarea___Config');
      alert("Removing config...");
      configItem.parentNode.removeChild(configItem);
    
      alert("Creating new editor...");
      var editor = new FCKeditor('j_id0:j_id2:editBlock:j_id33:theTextarea');
      editor.BasePath = '/apexpages/fckeditor/';
      editor.ReplaceTextarea();
     
      alert("Done...");
     }
    </script>
  4. Retest your page. The old editor should disappear and be replaced with the new one which includes all the fancy features of FCK.
How it works The swap() funtion gets called ~5 second after the page is loaded. While it isn't necessary to wait this long, it is necessary to wait until after the orgininal iFrame gets instantiated. (calling the function before it is there won't find anything...)
 
If you break it or mess it up bad, just remove the script block in your page - this isn't like Heretic's javascript injection which could really screw things up... Hopefully, they'll add the ability for folks to call custom parameters for FCK in the future, but this seems to work for now.
 
  • November 14, 2008
  • Like
  • 0
Hi,

I'm trying to incorporate a rich text textarea into a Visualforce page. I tried using the richtext="true" attribute,  but it seems like I don't have
very little control over the size and location of the textarea once it's rendered. This creates the rich text editor fine:

Code:
            <apex:pageBlockSection collapsible="true" title="My Form">        
                <apex:inputField value="{!event.Field1__c}"/>
                <apex:inputTextarea value="{!event.Field3__c}" id="specialTextArea" richtext="true"/>
                <apex:inputField value="{!event.Field2__c}"/>
            </apex:pageBlockSection>

 
but adding rows & cols attributes doesn't work, nor does adding css to the element (e.g. style="width:150px; height: 100px"). It just 
displays as wide as it can fit. I'm getting input for a SObject, so I'm using inputField elsewhere, but this seems to work as far as 
getting input in and out goes -- it gets and saves the field data with no problem.

Unlike inputField though, this won't automatically generate a label, so I also tried something like this:
Label <apex:inputTextarea value="{!event.Field3__c}" id="specialTextArea" richtext="true"/>

But that doesn't work either -- it just pushes the rich textarea over to the right.

Has anyone had any luck using this inside a PageBlockSection amongst other inputFields?

I also tried a few other WYSIWYG packages that I used in other work -- TinyMCE and the WYMeditor plugin for jquery. However,
I was not able to get either to work in the visualforce page. Both require a class or id attribute to identify the textArea to make
rich text. Identifying class doesn't seem to work. I also tried using the id, but the id seems to get transformed in the output.
Looking at the source of the html frame, I see something like
id="j_id0:j_id3:j_id4:j_id32:specialTextArea".
I also tried that id, but it didn't work either. If anyone has gotten another
WYSIWYG editor working with visualforce, I'd be interested
in hearing about that also.

thanks,
-paul


Message Edited by ptepper on 07-09-2008 01:21 PM