+ Start a Discussion
NonickNonick 

Visual Force Email Template - Date Format Issue and general VForce assistance

I'm looking for a method to format a datestamp field into a dd/mm/yyyy field.
The object we're refferencing is the default Opportunity object.

Currently returns:
Start Date:Tue Nov 25 00:00:00 GMT 2008
Would like it to return:
25/11/2008
The code for this is:
Start Date:{!relatedTo.EngagementStartDate__c}<br />

Anyone have any ideas? Everyone says to use the get, methods on a date, but our sforce resource stated that I can't do that in a template or merge document.

Regards,
N

PS
While we're here, I'd like to also merge in information of the Primary Contact. I know this is a one line requirement that has a whole slew of problems, but my alternative is writing a trigger that populates a new lookup field with the primary contact and using that field to drill to various pieces of information, this is a REALLY cumbersome solution, I'd rather call on the related contact roles list, but accounting the resource, if/else functions don't work on that list.


Message Edited by Nonick on 11-26-2008 05:24 PM
NonickNonick
Solved
format like this
{!day(cx.Start_Date__c)}/{!month(cx.Start_Date__c)}/{!year(cx.Start_Date__c)}
wacky


is there anything special I need to do to make an object an official child of another object?
I've got a master/detail field in the custom object linking it to the opportunity, but the opportunity doesn't list it as a child.
Trying to use the following code to pull the material:

Code:
    <table border="1" >
            <tr > 
                <th>Practice</th></tr>
            <apex:repeat var="cx" value="{!relatedTo.Practice_Service_Offering__r}">
            <tr>
            <td><a href="https://na1.salesforce.com/{!cx.id}">View</a></td>
               <td>{!cx.Practice__c}</td>
            </tr>
            </apex:repeat>                 
        </table>

 Suggestions?

edit:
actually it DOES show it in the apex explorer but the name of it is something along the lines of R00N20000001CFcUEAW
I don't want to hard code that beast anywhere.




Message Edited by Nonick on 11-26-2008 10:08 PM
mtbclimbermtbclimber
The problem here is that the child relationship name for your relationship is not set. We've seen this happen after creating new reference fields (lookups & master/detail relationships) under various conditions in the past and we believe we covered all the bases for any relationships you define as new now. 

When you encounter this scenario you can address it by navigating to the lookup or master-detail relationship field edit page and entering the desired value for the "Child Relationship Name" field. The best value for this is usually a qualified version of the Related List Label.

The value *should* default to the name qualified version of what you provide in the Related List label field in the custom field wizard for relationships going forward.


NonickNonick
That was exactly it, further research showed that the relationship was lost during a consolidation done before my time. Resetting the child worked well. The fact that the master/detail field was there but the relationship wasn't through me. Appreciate your help.
etoeto

Can someone please give me a hint where these functions are documented?

 

day(cx.Start_Date__c)

month(cx.Start_Date__c)

year(cx.Start_Date__c)
 
I assume there are lots of more nice helper-functions but I could not find anything in the visual force documentation.


regards

 

Ron WildRon Wild

Yes!  Documentation on these functions would be very helpful.  Anyone know where a complete list might be?

 

 

etoeto

It is not clearly documented, but you can use all formula field functions as described in the help section:

 

https://na5.salesforce.com/help/doc/en/customize_functions.htm

 

hth

ECDECD

{!day(cx.Start_Date__c)}/{!month(cx.Start_Date__c)​}/{!year(cx.Start_Date__c)}
Worked. But if those fields are blank, the two slashes "//" remains. Is there any way to hide them?

etoeto

try to surround it with an IF, e.g.

 

{!IF(ISBLANK(cx.Start_Date__c),'',day(cx.Start_Date__c)}/{!month(cx.Start_Date__c)​}/{!year(cx.Start_Date__c))}

RozRoz

Excellent!  Thanks for the date format.  Solved my problem before i had to ask the question!

 

;)