• JoyD
  • NEWBIE
  • 125 Points
  • Member since 2007

  • Chatter
    Feed
  • 4
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 34
    Replies

Hello.  I am running into an error after tweaking a previously-working AggregateResult line of code.  Does anyone have any guidance as to what is the best way to proceeed.

 

In the below code, I am trying to limit my query to the past seven days (note 'system.today()-7').   Unfortunately, I am receiving errors for the "ClosingDate__c = QueryDate" section of the AggregateResult line.  I have tried to insert brackets, single quotes, etc...and receive some sort of error message each time.  Can anyone provide some guidance?

 

Thanks in advance.

 

public Date QueryDate { get; set;}


QueryDate = (system.today() - 7);

AggregateResult[] ar = [SELECT sum(CustomerDollars__c) FROM Customers__c WHERE ClosingDate__c = QueryDate GROUP BY ClosingDate__c ORDER BY sum(CustomerDollars__c) desc LIMIT 1]; 

 

I am trying a basic public-accessible website and built one page to just display info that uses the standard controller, great, it works fine.

 

I then wrote an extension to get the related objects necessary, and it still works, UNTIL I try to actually USE one of the public variables (they have just a standard get and set) in the VF page.  I get the following error: 

Authorization Required 
You must first log in or register before accessing this page. 
If you have forgotten your password, click Forgot Password to reset it.

 

I have checked and under the Public Access Settings for that Site, I do have the Extension available.  I also checked and have given that profile Read access to the objects I access in the Extension.

 

Any help on debugging this further?  I can't figure out how to even do a System.debug on a Site, it's in my Extension to see if we ever get there, but I don't know how to get this to show up on the System Log :-(

 

So I have a visualforce wizard that takes you through each page to collect the info for the object.  On one of the pages, I want to allow them to add one or more of a custom child object (in this case, literally all the person's Children).

 

I can't seem to figure out how to structure this.  Do I need to create the child in the controller before I try to collect their info on the VF page?  But if they don't have any children, I don't want to have created a child already.  I assume I need a way to cycle through each child, but how?  Can you even add children to a parent that hasn't actually been saved yet?  Does it need a whole new controller or something?  I'm sure there's something out there I just don't know about yet.

 

The page looks like:

Checkbox if they have children

Default is unchecked

If user checks, then output panel appears to fill in info for first child

Buttons to save and done (go to next page), save and add another child (reload output panel blank for new child), etc

 

I've got the checkbox controlling the output panel, then got stuck on how this should be structured.  Once I do it for the Children, then I can do it for the other 5 child objects.

  • August 16, 2011
  • Like
  • 0

I must be missing some small but key point here.  Why do my VisualForce pages look like the old look and feel of SF before the UI update (not sure when that happened, maybe a year or two ago?)...

 

Instead of the white background with skinny colored line above each pageBlockSection title, it is the old UI of gray background, pageBlockSection title in white set in the much thicker colored line.

 

I tried checking the version of my pages (up-to-date), and the documentation, and I can't find anything...

  • August 15, 2011
  • Like
  • 0

There's nothing in the VisualForce Developer's Guide about this, but how do I match the functionality of a regular page layout with my VF?  I want to be tabbing DOWN the pageBlockSection, not ACROSS how it defaults.  I see no switch for this?

  • August 10, 2011
  • Like
  • 0

Is there a way to STOP the annoying auto-popup of the calendar picker for the Date field on the Events (Activities)?  I'd LOVE to turn it off on my Visualforce pages, but can't seem to do so.

  • July 14, 2011
  • Like
  • 0

Has anyone else noticed this or know how to fix it?  All the sudden (in the past month or two maybe?) I noticed that when running my Test classes, the Debug Log is cut far short of the full log.  For instance:

11:16:57.316 (1316050000)|WF_RULE_FILTER|[Account : Category excludes Client] AND
 [Account : Category excludes MHK Fin. Client] AND
 [Account : Mortgage Rep not equal to null] AND
 [Account : Category includes MHK Real Estate] AND
 [Account : Category excludes Private Client Services] AND
 [Account : Account Recor

 Thats the last section of my debug log - it cuts off in the middle of not only the code, but the sentence and even the word!  I don't think I've changed anything...

 

Obviously this is kind of an issue since my code is breaking well AFTER this point - and I have no way to debug it!  Help!

  • July 06, 2011
  • Like
  • 0

Is there a way to set the additional To or the CC fields when creating a Visualforce email template?  I can't find anything in the Developer's Guide or anywhere else.  We have two email fields on our Contact/Accounts (we use Person Accounts), so we need the emails to always go to both.

 

Previous to my learning VF, we used Conga merge and I was able to set this in the button parameters, so I am 99% sure it is possible...just not sure what the code is...

 

{!Recipient.Spouse_Email__c} gets me the correct field...now where to put it?

  • March 11, 2011
  • Like
  • 0

I am running a query on the Event object, and it's working until I tried grabbing a custom field on the User who is assigned (the Owner).  I already had standard fields pulling from the Owner, so not sure why it's not working for the custom field.  I pulled my naming from the schema browser a few different times, just to be sure...

 

Here's my query:

 

tempAppts = [SELECT WhoId, WhatId, OwnerId, Owner.FirstName, Owner.Profile__c, Owner.Name, Subject, StartDateTime, Result__c
	FROM Event
	WHERE WhoId = :contactID
	AND StartDateTime >= :yaynow
	AND Result__c != 'Rescheduled'];

OwnerId, Owner.FirstName, and Owner.Name work fine, but once I put in Owner.Profile__c I get an error on save.  I have tried OwnerId.Profile__c, Owner__r.Profile__c, etc.  The error message is strange as well, references "Name" instead of "Owner":

 


Save error: No such column 'Profile__c' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 

 

  • March 09, 2011
  • Like
  • 0

I want to pass the ID of the Contact from my VisualForce Email Template up to the Controller, via the Custom Component, so that the Controller can query Events for just this Contact.  However, I seem to be getting stuck at Component to Controller.

 

Per the VF Developer's Guide, under "Custom Component Controllers", step 3 says, "In the <apex:attribute> tag in your component definition, use the assignTo attribute to bind the attribute to the class variable you just defined."  However, I am finding this never sets the value in the Controller - just within the Component.  Is the Guide wrong or do I have an error?

 

Here is a snippet of the Component code:

 

<apex:component controller="EmailApptController" access="global">

    <apex:attribute name="ToID" type="ID" description="the account ID" assignTo="{!contactID}"/>
    <apex:attribute name="Something" type="String" description="something to assign" assignTo="{!something}"/>

 

 

And the relevant Controller:

 

public class EmailApptController {
	public List<Event> appts {get; set;}
	public String message {get; set;}
	public ID contactID {get; set;}
	public String something {get; set;}
	
	public EmailApptController() {
		datetime yaynow = datetime.now();
		appts = [SELECT WhoId, WhatId, OwnerId, Subject, StartDateTime, Result__c, Confirmation_Status__c, Location_Map_URL__c, Location__c, Location_Address__c, Location_City_State_Zip__c, Location_Directions__c, Location_Directions_2__c
					FROM Event
					WHERE WhoId = :contactID
					AND StartDateTime >= :yaynow
					AND Result__c != 'Cancelled'
					AND Result__c != 'Rescheduled'];
					
		if (appts.isEmpty()){
        	message = 'There are no pending appointments for this client: ' + contactID + ' and something is: '+ something;
        }
	}
	
}

 

 

contactID and 'something' always return null from the controller, but when I access them in the Component they are fine.

 

I have found this post in the wiki re Controller Component Communication, but it's way over my head and seems overkill if all I want to do is grab this one ID.  Any thoughts?

 

 

  • February 15, 2011
  • Like
  • 1

This should be super-simple, I'm just not seeing how to fix this.  I'd like to output HTML (a simple <br>) IF a certain condition is made.  Here is a snippet of my code:

 

<apex:outputField value="{!facility.Facility_Address_1__c}" />
{! IF(facility.Facility_Address_2__c!='','<br/>','NOPE')}
<apex:outputField value="{!facility.Facility_Address_2__c}" />

 

Basically, just want to output the first line of the address, if there is a second line to the address, add a new line break, then output the second line of the address.  Instead of a new line break, all I get is straight text, "<br/>" is stuck between the two address lines.

I also tried using br() and HTMLENCODE to no avail...even tried moving the text concatenation to the controller...I'm so lost...

  • January 06, 2011
  • Like
  • 0

I was just curious at what point of developing your Trigger, do you decide to move your code to a Class instead?  My Trigger keeps getting larger, but because I need to iterate through the Trigger.new, I haven't wanted to move everything out to a Class - but now I'm wondering if it would make life easier (though harder at first...)?

  • November 15, 2010
  • Like
  • 0

I'm unsure how to best do this...I would like to pass values from the Event (Date, Campaign, Name, Assigned To) to a page to open an Opportunity.  I tried just doing a URL, but when passing the Name (WhoId), it does a Contact ID which of course won't work because the Opp needs an Account (FYI, we use PersonAccounts).  Also, the Campaign (WhatId), and AssignedTo pass ID's and apparently the Opp page is looking for the name of the item, not the ID.

 

So I am wondering if there is a way to extract that info from the Event to push into a URL.

 

Or, do I need to resort to VisualForce?  I could recreate the New page for Opportunities, but I assume I'd still need to somehow pass the info from the Event through a button.  Would I then need to create a separate View page for Events, to pass the info through the viewstate (haven't worked with viewstate yet).  Or would it make sense to make an Event/Opp mashup page.

 

I can't just save an Opp to the database with the values I'm passing, there are many required fields that will still need to be filled out, hence why I'd like to go straight to the 'New' page.

 

Thanks for any help or pointing me in a direction...

  • October 25, 2010
  • Like
  • 0

I have a List of Events output to a VF page that I would like to group by the Assigned To person.  Right now, I just have that field output to one of the columns - but ideally would like to Group By just like a Report.  Currently using a PageBlockTable to output - but am open to whatever might work.  Is there a way to do this - I can't seem to find anywhere?

 

I would assume my custom controller would need to somehow handle this, but I can't seem to understand how to make that work.  Here's my SOQL query if it helps in the understanding at all:

 

SELECT Who.Name, WhatId, StartDateTime, Result__c, Owner.Name, LastModifiedDate, LastModifiedBy.Name, Appointment_Type__c, ActivityDateTime, ActivityDate, Subject
                FROM Event
                WHERE Result__c != 'Cancelled' 
                	AND Result__c != 'No Show' 
                	AND ActivityDate >= :firstDateToUse
                	AND ActivityDate <= :secondDateToUse
                ORDER BY Owner.Name, ActivityDateTime

 

 

The VF page lists off all the information for someone to update the Results of all the appointments yesterday.  Currently, we do this by going to a Report, opening each appointment, updating it, going back to Report...etc.

 

Thanks in advance!

  • August 02, 2010
  • Like
  • 0

Hi all - just got back from the DEV 501 course and wrote my first VF page and custom controller from scratch!  Now looking to tweak certain things.

 

Is there a function to tell if the user has made a change to a value on a VF page?  In the UI, we have the function isChanged, and in Apex, we have Trigger.old and Trigger. new - but what about in a VF page?

 

If the context matters, here's the project:

Page containing a form that lists multiple sObjects by rows.  Two of the columns contain inputFields so the user can change multiple values all from one page, then hit Submit.  I use a SOQL query to put the sObjects into a List in the controller - then when the user hits Submit, I call update on that List.  Perhaps there's a better way to architect this?

 

Anyway - my concern is that all the sObjects are updated, whether or not they were changed (therefore the Last Modified Date and By are updated).  Thought I could build a 'changed' List out of ONLY those that were changed and just update that, but can't figure out how to tell what has changed.

 

Thanks for any help you can give...

  • July 28, 2010
  • Like
  • 1
I am working on a simple (or so I thought) Employee and PTO app.  The PTO object looks up to the Employee.  I would like to automate the creation of PTO items at different times - 90 days after the Employee start date, and yearly on their anniversary (ie create a new PTO item for this Employee when eligible, filling in the Amount with a field on the Employee, etc).  I have all the fields in place for this but realized I don't know how to make it happen.
 
I have searched everywhere I know of, and I have gleaned that 1. I cannot use existing Workflows to do a cross-object 'anything' (except on children), 2. I cannot use existing SF functionality to automate creation of anything.  It seems it can be programmed somehow though?
 
If anyone can help by pointing me in the right direction that would be great.  I have programming background but haven't programmed in SF besides doing the basic Eclipse IDE thingy - setting up an object and creating fields.  I thought I read something about Apex or AJAX - but can't find any 'Here's how to get started' tutorials or if that's even the right place to look for this.
 
I'd love to start programming with this and it seems simple enough, so I hope someone can help!
  • October 10, 2008
  • Like
  • 0
Hi, I'm getting going on formula fields and had a question I can't seem to find asked on the forums here yet.  I have a Formula field, Photo, that essentially assembles a URL based on the client's name.  Works fine except for when the file isn't there (ie, we haven't uploaded a photo for them yet).
 
Is there any way to 'trap' the "The page cannot be found", HTTP Error 404 returned, so that instead of an ugly missing image icon (white with red X), I can display an image of my choosing (ie blank pixel, or "no photo taken yet" image).
 
Any help is greatly appreciated!
  • August 06, 2008
  • Like
  • 0

I want to pass the ID of the Contact from my VisualForce Email Template up to the Controller, via the Custom Component, so that the Controller can query Events for just this Contact.  However, I seem to be getting stuck at Component to Controller.

 

Per the VF Developer's Guide, under "Custom Component Controllers", step 3 says, "In the <apex:attribute> tag in your component definition, use the assignTo attribute to bind the attribute to the class variable you just defined."  However, I am finding this never sets the value in the Controller - just within the Component.  Is the Guide wrong or do I have an error?

 

Here is a snippet of the Component code:

 

<apex:component controller="EmailApptController" access="global">

    <apex:attribute name="ToID" type="ID" description="the account ID" assignTo="{!contactID}"/>
    <apex:attribute name="Something" type="String" description="something to assign" assignTo="{!something}"/>

 

 

And the relevant Controller:

 

public class EmailApptController {
	public List<Event> appts {get; set;}
	public String message {get; set;}
	public ID contactID {get; set;}
	public String something {get; set;}
	
	public EmailApptController() {
		datetime yaynow = datetime.now();
		appts = [SELECT WhoId, WhatId, OwnerId, Subject, StartDateTime, Result__c, Confirmation_Status__c, Location_Map_URL__c, Location__c, Location_Address__c, Location_City_State_Zip__c, Location_Directions__c, Location_Directions_2__c
					FROM Event
					WHERE WhoId = :contactID
					AND StartDateTime >= :yaynow
					AND Result__c != 'Cancelled'
					AND Result__c != 'Rescheduled'];
					
		if (appts.isEmpty()){
        	message = 'There are no pending appointments for this client: ' + contactID + ' and something is: '+ something;
        }
	}
	
}

 

 

contactID and 'something' always return null from the controller, but when I access them in the Component they are fine.

 

I have found this post in the wiki re Controller Component Communication, but it's way over my head and seems overkill if all I want to do is grab this one ID.  Any thoughts?

 

 

  • February 15, 2011
  • Like
  • 1

Hi all - just got back from the DEV 501 course and wrote my first VF page and custom controller from scratch!  Now looking to tweak certain things.

 

Is there a function to tell if the user has made a change to a value on a VF page?  In the UI, we have the function isChanged, and in Apex, we have Trigger.old and Trigger. new - but what about in a VF page?

 

If the context matters, here's the project:

Page containing a form that lists multiple sObjects by rows.  Two of the columns contain inputFields so the user can change multiple values all from one page, then hit Submit.  I use a SOQL query to put the sObjects into a List in the controller - then when the user hits Submit, I call update on that List.  Perhaps there's a better way to architect this?

 

Anyway - my concern is that all the sObjects are updated, whether or not they were changed (therefore the Last Modified Date and By are updated).  Thought I could build a 'changed' List out of ONLY those that were changed and just update that, but can't figure out how to tell what has changed.

 

Thanks for any help you can give...

  • July 28, 2010
  • Like
  • 1

Hello.  I was wondering if anyone could give me some guidance to the below issue.  Thanks in advance.

 

I have two objects

1) TransactionCategory__c contains details about transaction categories.

2) Transactions__c contains individual transactions by customers. 

* TransactionCategory__c is the parent of Transactions__c.

 

I am developing an edit page for new Transactions__c records.  This page will collect details about each transaction.

 

The Transactions_c page contains a picklist of transaction categories - so each transaction can be tied to a specific TransactionCategory__c.

 

Certain TransactionCategory__c records have a Risk__c field value of "true".  These are risky transactions that need to be more thoroughly documented than other transactions.

 

My desire is to gather this needed additional risky Transaction__c information in an additional outputPanel - but I only want to show this outputPanel for those TransactionCategory__c records with a Risk__c value of "true".  Otherwise, I do not want to display the outputPanel.

 

Unfortunately, I have yet to be able to pass a valid value of the Risk__c field based on the TransactionCategory__c record choice selection (as selected by TransTypeChoices).

 

I have tried modifying the actionSupport, using a param, creating a list, etc, etc, etc - in order to pass the Risk__c value...but nothing seems to work.

 

Any thoughts would definitely be appreciated.  Below is the relevant VF and controller code.

 

VF PAGE
// a list of transaction types are provided via a picklist
<apex:pageblockSectionItem > 
<apex:outputLabel value="Transaction Category:" for="TransCat"/> 
<apex:selectList id="TransCat" value="{!NewTrans.TransactionCategory__c}" size="1" title="Menu">
<apex:selectOptions value="{!TransTypeChoices}">
</apex:selectOptions>
<apex:actionSupport event="onchange" rerender="AdditionalInfo">
</apex:actionSupport>
</apex:selectList>
</apex:pageblockSectionItem>


// The below section should only be displayed when the TransactionCategory__c's Risk__c value = true.
// Unfortunately, this is not working as desired.
<apex:outputPanel id="AdditionalInfo">
<apex:outputPanel rendered="{NewTrans.TransactionCategory__r.Risk__c = true}">
<apex:inputField value="{!NewTrans.AddQuestion1__c}" id="Add1"/> 
<apex:inputField value="{!NewTrans.AddQuestion2__c}" id="Add2"/> 
<apex:inputField value="{!NewTrans.AddQuestion3__c}" id="Add3"/> 
</apex:outputPanel>
</apex:outputPanel>




CONTROLLER
// Creating a new Transaction__c record
public Transactions__c NewTrans {  
get {
if (NewTrans == null)      
NewTrans = new Transactions__c();
return NewTrans;
}
set;
}

 

I am trying to output a custom picklist in a visualforce page

 

This works fine - but I'm lost to how to make it display as a drop-down

 

<apex:page controller="sampleCon">
    <apex:form >
        <apex:selectList value="{!countries}" multiselect="true">
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><p/>

        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>

    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
</apex:page>

 

Please can someone point me in the right direction - thanks

I must be missing some small but key point here.  Why do my VisualForce pages look like the old look and feel of SF before the UI update (not sure when that happened, maybe a year or two ago?)...

 

Instead of the white background with skinny colored line above each pageBlockSection title, it is the old UI of gray background, pageBlockSection title in white set in the much thicker colored line.

 

I tried checking the version of my pages (up-to-date), and the documentation, and I can't find anything...

  • August 15, 2011
  • Like
  • 0

[Apologies for the dupe post. Misposted to another discussion area initially.]

 

I'm building a visualforce page to replace the default contact detail view.

 

We've got some custom fields that we know want to modify the output of - relatively trivial html/css tweaks to highlight the fields in unique ways. But we otherwise want to keep the layout and features the out of the box contact view/declarative definitions of stuff give us.

 

I see that I can customize <apex:detail> by explicitly turning things off through attributes... but I think I need to rebuild it "manually" with all the appropriate and as granular as possible apex elements and then do the wee bits of html/operations on displaying the values of the custom fields I care about to get my exception.

 

This is pretty tedious and I am new to this. Am I missing anything obvious? Are there examples or tools that'll help me reproduce a standard view as a custom visualforce page with granular elements easily, so I can focus on just my modifications?

 

Matt

 



Is there a way to STOP the annoying auto-popup of the calendar picker for the Date field on the Events (Activities)?  I'd LOVE to turn it off on my Visualforce pages, but can't seem to do so.

  • July 14, 2011
  • Like
  • 0

Has anyone else noticed this or know how to fix it?  All the sudden (in the past month or two maybe?) I noticed that when running my Test classes, the Debug Log is cut far short of the full log.  For instance:

11:16:57.316 (1316050000)|WF_RULE_FILTER|[Account : Category excludes Client] AND
 [Account : Category excludes MHK Fin. Client] AND
 [Account : Mortgage Rep not equal to null] AND
 [Account : Category includes MHK Real Estate] AND
 [Account : Category excludes Private Client Services] AND
 [Account : Account Recor

 Thats the last section of my debug log - it cuts off in the middle of not only the code, but the sentence and even the word!  I don't think I've changed anything...

 

Obviously this is kind of an issue since my code is breaking well AFTER this point - and I have no way to debug it!  Help!

  • July 06, 2011
  • Like
  • 0

I am running a query on the Event object, and it's working until I tried grabbing a custom field on the User who is assigned (the Owner).  I already had standard fields pulling from the Owner, so not sure why it's not working for the custom field.  I pulled my naming from the schema browser a few different times, just to be sure...

 

Here's my query:

 

tempAppts = [SELECT WhoId, WhatId, OwnerId, Owner.FirstName, Owner.Profile__c, Owner.Name, Subject, StartDateTime, Result__c
	FROM Event
	WHERE WhoId = :contactID
	AND StartDateTime >= :yaynow
	AND Result__c != 'Rescheduled'];

OwnerId, Owner.FirstName, and Owner.Name work fine, but once I put in Owner.Profile__c I get an error on save.  I have tried OwnerId.Profile__c, Owner__r.Profile__c, etc.  The error message is strange as well, references "Name" instead of "Owner":

 


Save error: No such column 'Profile__c' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 

 

  • March 09, 2011
  • Like
  • 0

Hello.  I am running into an error after tweaking a previously-working AggregateResult line of code.  Does anyone have any guidance as to what is the best way to proceeed.

 

In the below code, I am trying to limit my query to the past seven days (note 'system.today()-7').   Unfortunately, I am receiving errors for the "ClosingDate__c = QueryDate" section of the AggregateResult line.  I have tried to insert brackets, single quotes, etc...and receive some sort of error message each time.  Can anyone provide some guidance?

 

Thanks in advance.

 

public Date QueryDate { get; set;}


QueryDate = (system.today() - 7);

AggregateResult[] ar = [SELECT sum(CustomerDollars__c) FROM Customers__c WHERE ClosingDate__c = QueryDate GROUP BY ClosingDate__c ORDER BY sum(CustomerDollars__c) desc LIMIT 1]; 

 

Wow, I just can't seem to figure this simple thing out.  In a visualforce template I want to create a link to an object record. 

 

I've seen examples like this

 

 

({!LEFT($Api.Partner_Server_URL_140, FIND(".com/",$Api.Partner_Server_URL_140)+3)

 

but shouldn't I be able to use a simple relative URL to get this to work?

 

 

 

 

A new record was created!  <a href="/{!RelatedTo.ID}">Click here</a>  to see it.

 

 

However, when the email gets sent out the link becomes "http://5008000000dmoskaax/" and not "http://na8.salesforce.com/5008000000dmoskaax"

 

 

 

Any idears?

 

 

 

Tyler

 

 

 

I want to pass the ID of the Contact from my VisualForce Email Template up to the Controller, via the Custom Component, so that the Controller can query Events for just this Contact.  However, I seem to be getting stuck at Component to Controller.

 

Per the VF Developer's Guide, under "Custom Component Controllers", step 3 says, "In the <apex:attribute> tag in your component definition, use the assignTo attribute to bind the attribute to the class variable you just defined."  However, I am finding this never sets the value in the Controller - just within the Component.  Is the Guide wrong or do I have an error?

 

Here is a snippet of the Component code:

 

<apex:component controller="EmailApptController" access="global">

    <apex:attribute name="ToID" type="ID" description="the account ID" assignTo="{!contactID}"/>
    <apex:attribute name="Something" type="String" description="something to assign" assignTo="{!something}"/>

 

 

And the relevant Controller:

 

public class EmailApptController {
	public List<Event> appts {get; set;}
	public String message {get; set;}
	public ID contactID {get; set;}
	public String something {get; set;}
	
	public EmailApptController() {
		datetime yaynow = datetime.now();
		appts = [SELECT WhoId, WhatId, OwnerId, Subject, StartDateTime, Result__c, Confirmation_Status__c, Location_Map_URL__c, Location__c, Location_Address__c, Location_City_State_Zip__c, Location_Directions__c, Location_Directions_2__c
					FROM Event
					WHERE WhoId = :contactID
					AND StartDateTime >= :yaynow
					AND Result__c != 'Cancelled'
					AND Result__c != 'Rescheduled'];
					
		if (appts.isEmpty()){
        	message = 'There are no pending appointments for this client: ' + contactID + ' and something is: '+ something;
        }
	}
	
}

 

 

contactID and 'something' always return null from the controller, but when I access them in the Component they are fine.

 

I have found this post in the wiki re Controller Component Communication, but it's way over my head and seems overkill if all I want to do is grab this one ID.  Any thoughts?

 

 

  • February 15, 2011
  • Like
  • 1

I'm trying to use VisualForce for the first time and since I have some HTML knowledge thought the email template might be the easiest place for me to start - I've got it complete but unfortunately keep getting errors upon save, here is what I have so far:

 

<messaging:emailTemplate recipientType="User"
relatedToType="Opportunity"
subject="New Bookings{!relatedTo.Account.Name}"
replyTo="new_bookings@spiceworks.com">
<messaging:htmlEmailBody >
<b>Customer Name:</b> {!relatedTo.Account.Name} <br/>
<b>Date of Booking:</b> {!Opportunity.CloseDate} <br/>
<b>Total Committed Booking Amount:</b> {!Opportunity.Amount} <br/>
<b>Total At Risk Booking Amount:</b>{!OpptyLineItem__c.At_Risk_Bookings_Amount__c} <br/>
<b>Grand Total Booking:</b> {!Opportunity.Amount} <br/> <br/>

<table width="100%"
     style="border-style: solid; border-width: 1px; border-color: #00000">
<u><tr><th>Timeframe</th>
<th>Product</th>
<th>Description</th>
<th>Geo</th>
<th>Volume (K)</th>
<th>CPM/CPL/Cost Per Month</th>
<th>Value</th>
</tr></u>
<tr>
<!--{!relatedTo.OpptyLineItem__c.Name}-->
<td>{!relatedTo.OpptyLineItem__c.StartDate__c} - {!relatedTo.OpptyLineItem__c.EndDate__c} </td>
<td>{!relatedTo.OpptyLineItem__c.ProductId__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Description__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Region__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Quantity__c}</td>
<td>{!relatedTo.OpptyLineItem__c.ListPrice__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Total__c}</td>
</tr>
</table><br/><br/>

<b>Total:</b> {!Opportunity.Amount} <br/>
<b>Salesforce IO Number:</b> {!Opportunity.IONumber__c} <br/>
<b>Link to IO:</b> {!Opportunity.IO_Customer_URL__c} <br/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

I keep getting an error listed as: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'

 

I suspect this is because I'm trying to call the related Account data and Opportunity Line Item data into the template but don't understand why it won't let me do that since both have direct relationships with the Opportunity object.

 

Help!

  • September 23, 2010
  • Like
  • 0

Hi,

 

I've run into a very annoying problem. I have a simple visualforce page that displayes an organizations address pulling from the organization fields, like so:

 

 

<apex:outputText value="{!SUBSTITUTE($Organization.Street, '\n', '<br />')}" escape="false" /><br /> <apex:outputText value="{!$Organization.City}" />, <apex:outputText value="{!$Organization.State}" />&nbsp;<apex:outputText value="{!$Organization.Country}" />&nbsp;&nbsp;&nbsp;<apex:outputText value="{!$Organization.PostalCode}" /> <br />

As you can see I'm tyring to replace the new line character with html break tags. Unfortunately it doesn't seem to be picking up the newline character. I really don't want to write custom controller just to generate a string with proper line breaks (this is all the controller would do for this page, I have no need for anything else). Is there a different character for line breaks that I'm missing? 

 

 

 

  • April 22, 2009
  • Like
  • 0

Is there an easy way to only display the Time of a DateTime object in VisualForce?

 

Also is there an easy way to display the Day-of-the-week like 'Friday' in VisualForce?

 

Currently, I'm using a switch statement taken from the pdf on Formulas, but am wondering if there is a better method:

{!CASE(MOD( TODAY() - DATE(1900, 1, 7), 7),0, "Sunday",1, "Monday",2, "Tuesday",3, "Wednesday",4, "Thursday",5, "Friday",6, "Saturday", "Error")}

 

Thanks

Parker