• Jereriah Manning
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I'm trying to return today's date to a String (a lot more going on), but here's the issue in code and log.

CODE
Datetime todayDate = Date.Today();
Integer todayDay = todayDate.Day();
String todayDateString = todayDate.format('dd-MMM-yyyy hh:mm aaa');
finalMergefieldMap.put('{!Today}', todayDateString);
System.debug('****************************** Date.Today() ' + Date.Today());
System.debug('****************************** Day of Today ' + todayDay );
System.debug('****************************** todayDateString ' + todayDateString );

LOG (trimmed for legibility)
11:19:12.112 (112942417)|USER_DEBUG|[285]|DEBUG|****************************** Date.Today() 2014-07-25 00:00:00
11:19:12.113 (113000818)|USER_DEBUG|[286]|DEBUG|****************************** Day of Today 24
11:19:12.113 (113029002)|USER_DEBUG|[287]|DEBUG|****************************** todayDateString 24-Jul-2014 06:00 PM

Where is the switch between 25 and 24 happening? I checked my Company Profile for timezone.  I did the same on my User record and they are both correctly set to -6:00 (Colorado, USA).

Any help here is most welcome. I don't want to stamp the records with yesterday's date.

Thanks!
~J

@Conga_Jereriah
Is there a way to search a text field and create a List or Map with entries each time a specific string of characters is in the text field? I'm looking for a way to go through a text (not Rich) field and make merge field replacements, in much the same way the standard email templates work in SF.

Unlike a standard email, my text field can have fields from up to 4 objects + Sending User fields; an email template on steroids.

For instance:

{!Contact.FirstName} {!Contact.LastName}
{!Account.BillingStreet}
{!Account.BillingCity} etc...

Dear {!Contact.FirstName},

Account Name: {!Account.Name}

Possible {!Lead.Name} in here for good measure. This is my body. More fields possible down below. {!Custom_object__c.Field} too!

Sent by: {!User.FirstName} {!User.LastName}

I want a List/Map for each object in the above text field with the field merge field name in it.

List<String> contactFields as
{!Contact.FirstName}
{!Contact.LastName}
etc... 
List<String> accountFields
List<String> LeadFields
List<String> customerObjectFields
List<String> sendingUserFields

OR

Map<String, String> contactFields ('{!Contact.FirstName}', 'FirstName')
etc...
Map<String, String> accountFields ('{!Account.Name}', 'Name')

Once I have the Lists, I can do some trimming/looping to create SOQL statements and return the field values for the merge fields. In essence, I'm trying to loop through a single field.

I'll worry about doing the actual merge once I get over this hurdle as it will take another pass through the text field making replacements. I actually feel better about this one though—a while loop checking for ‘{!’ In the text field.

Thanks in advance!
~J

@Conga_Jereriah
I'm trying to return today's date to a String (a lot more going on), but here's the issue in code and log.

CODE
Datetime todayDate = Date.Today();
Integer todayDay = todayDate.Day();
String todayDateString = todayDate.format('dd-MMM-yyyy hh:mm aaa');
finalMergefieldMap.put('{!Today}', todayDateString);
System.debug('****************************** Date.Today() ' + Date.Today());
System.debug('****************************** Day of Today ' + todayDay );
System.debug('****************************** todayDateString ' + todayDateString );

LOG (trimmed for legibility)
11:19:12.112 (112942417)|USER_DEBUG|[285]|DEBUG|****************************** Date.Today() 2014-07-25 00:00:00
11:19:12.113 (113000818)|USER_DEBUG|[286]|DEBUG|****************************** Day of Today 24
11:19:12.113 (113029002)|USER_DEBUG|[287]|DEBUG|****************************** todayDateString 24-Jul-2014 06:00 PM

Where is the switch between 25 and 24 happening? I checked my Company Profile for timezone.  I did the same on my User record and they are both correctly set to -6:00 (Colorado, USA).

Any help here is most welcome. I don't want to stamp the records with yesterday's date.

Thanks!
~J

@Conga_Jereriah
Is there a way to search a text field and create a List or Map with entries each time a specific string of characters is in the text field? I'm looking for a way to go through a text (not Rich) field and make merge field replacements, in much the same way the standard email templates work in SF.

Unlike a standard email, my text field can have fields from up to 4 objects + Sending User fields; an email template on steroids.

For instance:

{!Contact.FirstName} {!Contact.LastName}
{!Account.BillingStreet}
{!Account.BillingCity} etc...

Dear {!Contact.FirstName},

Account Name: {!Account.Name}

Possible {!Lead.Name} in here for good measure. This is my body. More fields possible down below. {!Custom_object__c.Field} too!

Sent by: {!User.FirstName} {!User.LastName}

I want a List/Map for each object in the above text field with the field merge field name in it.

List<String> contactFields as
{!Contact.FirstName}
{!Contact.LastName}
etc... 
List<String> accountFields
List<String> LeadFields
List<String> customerObjectFields
List<String> sendingUserFields

OR

Map<String, String> contactFields ('{!Contact.FirstName}', 'FirstName')
etc...
Map<String, String> accountFields ('{!Account.Name}', 'Name')

Once I have the Lists, I can do some trimming/looping to create SOQL statements and return the field values for the merge fields. In essence, I'm trying to loop through a single field.

I'll worry about doing the actual merge once I get over this hurdle as it will take another pass through the text field making replacements. I actually feel better about this one though—a while loop checking for ‘{!’ In the text field.

Thanks in advance!
~J

@Conga_Jereriah
Hi All, I wanted to retrieve Salesforce Id of a field in Apex code. Any Idea? Thanks
  • December 03, 2010
  • Like
  • 0

Hi,

 

I have a visualforce email template which is related to a custom object. In the template I have the following line where Agenda_Objective__c is a long text area.

 

 

<apex:outputText value="{!relatedTo.Agenda_Objective__c}"/>

 

 If there are any line breaks in the field in the custom object, they do not come through in the email template.

E.G. if the field contains the text:

 

Test1

Test2

Test3

 

the mail will display

 

Test1 Test2 Test3

 

Is there any way of preserving the line breaks? I could use outputfield instead of outputtext but this puts extra javascript into the mail which causes an error in my email client.

 

  • December 14, 2009
  • Like
  • 0

Hi

I don't know what is the problem in the following query. I am getting "Expected identifier" error...

Can anyone help me find this?

Thanks

Muthu.

<html>
<head>
<script type="text/javascript" src="/soap/ajax/8.0/connection.js"></script>
<script type="text/javascript">

function init()
{
 deleteRecords();
}
function deleteRecords(fkId)
{       
    var sql = "Select Id FROM myEntity Where fkId__c = '" + fkId + "'";
   
    var qr1 = getRecords(sql); //getRecords returns queryResult...and I am getting records

    if (qr1.length > 0)
    {
 var p_ids = new Array(qr1.length);
    
 for (var i = 0; i < qr1.length; i++)
 {
  var record1 = qr1[i];
         p_ids[i] = record1.Id;        
 }    

        var p_csr = sforce.delete([p_ids]);
    }         
}

</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>