• nelloC
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 33
    Replies

I suspect this may be a bug but someone please tell me otherwise if it's not. I've just been pulling my hair out for the last few hours...

 

I have the following piece of code for example:

public PageReference PageInit(){
PageReference result = new PageReference('/apex/MyVisualforcePage');
result.getParameters().put('subject', EncodingUtil.urlEncode('Hi how\'s it going....', 'UTF-8'));
return result
}

 When the method was called it returned the following url:

https://na7.salesforce.com/apex/MyVisualforcePage?subject=Hi%2Bhow%2527s%2Bit%2Bgoing....

Which was obviously causing problems. The text ending up looking like this "Hi+how%27s+it+going...." in my visualforce page textbox.

 

But an earlier page I had written a few months back, given the save parameter value was returning the following url:

https://na7.salesforce.com/apex/MyOtherEarlierPage?subject=Hi+how's+it+going....

 

I finally found the reason, my new visualforce page had an API Version of 19.0, whereas the earlier page was at 16.0. I changed my new page to API Version 18.0 and all is working fine now.

 

The encoded parameter value becomes corrupted, by the way, when the PageReference getUrl() is called. EncodingUtil.urlEncode() seems to be functioning normally.

 

Any similiar problems, comments, or explanations are welcome. It would be good to find out what's going on here.

 

I have a test method calling a controller method that contains the following code:

My_Custom_Settings__c emailCustomSettings = My_Custom_Settings__c.getOrgDefaults();
if (mycustomSettings == null)
mycustomSettings = new My_Custom_Settings__c(SetupOwnerId=UserInfo.getOrganizationId(), Last_Remove_Date__c=null);
emailcustomSettings.Sf_Instance__c = sfInstance;
upsert emailCustomSettings;

 This code runs without issue in the application but when called from the test method (where the organization settings already exist and an update should occur) it fails with the following errror:

System.DmlException: Update failed. First exception on row 0 with id a03A0000001bfkHIAQ; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

 

Interestingly the id it gives in the exception message is a different id to the existing organization settings record...

 

I've also just discovered that his method works fine if called from a test method in isolation. But it fails when run as part of class containing many test methods some of which call methods that access this custom setting.

 

Something very strange going on here, possibly a bug?

 

We have recently raised a case with Salesforce support because our app is failing on installation. From the little information I have got back from support it seems to be failing on instantiating an innerclass. See below:

 

UtilityClass.ResolvedTemplate resolvedTemplate = new UtilityClass.ResolvedTemplate();

 Where the inner class is as follows:

 

public with sharing class UtilityClass {
...
... ... // Inner classes public class ResolvedTemplate { public ResolvedTemplate () { Subject = ''; Body = ''; TemplateAttachments = new List<Attachment>(); } public string Subject { get; private set; } public string Body { get; private set; } public List<Attachment> TemplateAttachments { get; private set; } } ... ... }

The app installation failed with the following message:

Your requested install failed. Please try this again.
None of the data or setup information in your salesforce.com organization should have been affected by this error.
If this error persists, contact salesforce.com Support through your normal channels and reference number: 1043502955-384 (-1811678545)

 

We're told by support the following error occurred on installation:

[DeployMessage] FAILURE problem: Invalid type: UtilityClass.Reso= lvedTemplate fullName: EmailAuthorController id null fileName: classes/Emai= lAuthorController.cls lineNumber: 1070

 

My problem is this. We have been informed that our case has identified a bug but as yet they haven't told us what the bug is. We're working on trying to get that information. But in the meantime has anyone else experienced this bug possibly? Or experienced a similiar problem? Or have any useful information on this issue? At the moment our app is uninstallable and we're completely in the dark as to what the bug actually is. If I can get some information on the bug we can probably find a work around until the fix is available. I thought its worth a shot posting it on here just in case anyone else has experienced the same problem.

 

Thanks

 

 

 

I was looking on here for a formula that generates a thread id correctly but couldn't find anything. So I've come up with one that does the job. I thought someone else might find this useful.

 

 

"ref:"&LEFT( $Organization.Id , 4 )&
IF(BEGINS(RIGHT($Organization.Id,11), '0000000'), RIGHT($Organization.Id,4), 
 IF(BEGINS(RIGHT($Organization.Id,11), '000000'), RIGHT($Organization.Id,5), 
  IF(BEGINS(RIGHT($Organization.Id,11), '00000'), RIGHT($Organization.Id,6), 
   IF(BEGINS(RIGHT($Organization.Id,11), '0000'), RIGHT($Organization.Id,7), 
    IF(BEGINS(RIGHT($Organization.Id,11), '000'), RIGHT($Organization.Id,8),
     IF(BEGINS(RIGHT($Organization.Id,11), '00'), RIGHT($Organization.Id,9),
      IF(BEGINS(RIGHT($Organization.Id,11), '0'), RIGHT($Organization.Id,10), RIGHT($Organization.Id,11)
      )
     )
    )
   )
  )
 )
)
&"."&LEFT( Id , 4 )&
IF(BEGINS(RIGHT(Id,11), '0000000'), RIGHT(Id,4), 
 IF(BEGINS(RIGHT(Id,11), '000000'), RIGHT(Id,5), 
  IF(BEGINS(RIGHT(Id,11), '00000'), RIGHT(Id,6), 
   IF(BEGINS(RIGHT(Id,11), '0000'), RIGHT(Id,7), 
    IF(BEGINS(RIGHT(Id,11), '000'), RIGHT(Id,8),
     IF(BEGINS(RIGHT(Id,11), '00'), RIGHT(Id,9),
      IF(BEGINS(RIGHT(Id,11), '0'), RIGHT(Id,10), RIGHT(Id,11)
      )
     )
    )
   )
  )
 )
)
&":ref"

 

 

  • April 17, 2010
  • Like
  • 0

I'm sending an email with attachments using SingleEmailMessage. An EmailFileAttachment[] List is created to contain the attachments which are within the specified 10mb limit for all attachments but when the attachments exceed 2mb in size the Apex heap size limit is exceeded.

 

My question simply is this: how are files, of up to 10mb, attached to an email using the SingleEmailMessage class without getting 'System.Exception: Apex heap size too large'?

 

 

// Create EmailMessage and assign parameters
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Support');
mail.setSubject('New Case Created : ' + case.Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');
mail.setTargetObjectId(case.contactId);
mail.setWhatId(case.Id);

// Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength 
                     from Attachment
                     where ParentId = :case.Id])
{
  // Add to attachment file list
  Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
  efa.setFileName(a.Name);
  efa.setBody(a.Body);
  fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);

// Send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })

 

I came up against this issue a couple of months back, posted it, but got no response. So apologies, I'm posting again in the hope that I can finally find a solution.

 

Would appreciate any responses on this one, even if it's half a guess. Thanks in advance.

SingleEmailMessage
  • April 09, 2010
  • Like
  • 0

I have a Visualforce page containing a commandButton that takes a user selected option from one selectList to another.

<apex:commandButton value=">>" id="to_select_add" action="{!AddToContact}"/>

It's a button users may click on more than a few times in quick succession to make their selection. Yesterday an intermittant problem occurred where all data was lost on the form after clicking the button. After debugging it transpired that each time the bug occurred a debug log with the line:

Log Element thePage called method {!checkManageability} returned type PageReference: none

was generated and the subsequent debug log showed that the constructor was called on the visualforce page controller. The instance of the apex controller appears to have been lost and a new instance created.

 

Yesterday it happened regularly. I have tried to replicate this problem today and only managed to see it happen once after many attempts!?

Can anyone, preferably Salesforce, shed any light on this behaviour. It's worrying and annoying as there seems to be no information to go on and therefore no possiblilty of getting a handle on this issue.

 

Please respond if you have experienced a similiar issue.

 

Thanks

Message Edited by nelloC on 03-23-2010 04:43 PM
  • March 23, 2010
  • Like
  • 0

I'm getting the following error when trying to upgrade a managed package into our test org:

 

Your requested install failed. Please try this again.
None of the data or setup information in your salesforce.com organization should have been affected by this error.
If this error persists, contact salesforce.com Support through your normal channels and reference number: 497370194-3524 (-459893822)
 
A new install though, completes without error.
 
I've filed a support case # 03397794
 
Thanks
Message Edited by nelloC on 03-17-2010 02:39 PM
  • March 17, 2010
  • Like
  • 0

I have a dynamic soql statement like this for example:

 

Sobject relObj;
relObj = Database.query('Select Id, ns__user__c, ns__Distribution_List__r.Name from ns__Distribution_List_User__c where id = \'a0aA0000000aaAAAAA\'');
String listName = String.valueOf(relObj.get('ns__Distribution_List__r.Name'));

Which is retrieving a parent relationship name field.
The query runs fine but the get() fails: Invalid field. It doesn't recognise 'ns_Distribution_List__r.Name'.
How is the parent relationship name field data retrieved?

 

Thanks

 

Message Edited by nelloC on 03-09-2010 08:40 AM
  • March 09, 2010
  • Like
  • 0

I have a apex method within a class that has "with sharing". It is run by a user that has a profile very much like to a Read Only profile - i.e. doesn't have View All Data permission. The following code is attempted:

 

Schema.SObjectType obj = gd.get('Organization'); Map<String, Schema.SObjectField> M = obj.getDescribe().fields.getMap() ;

But fails on the second line with a "Attempt to de-reference a null object" - variable obj is null, the SObjectType for Organization was not retrieved. I change the class to "without sharing" and obj is no longer null but M is blank. No fields were retrieved. If I give the user View All Data permission, everything is fine.

Is this a bug? I was lead to believe that "without sharing" ensures that the sharing rules are not enforced. And I read that View All Data also circumvents records based sharing. But there's something not quite equal here. How are the permissions gained to be able to perform the field describe on the Organization object within an apex class without giving the user View All Data permission?

 

This is a little worrying, any help much appreciated. Thanks.


 

  • March 08, 2010
  • Like
  • 0

I'm attempting to send an email with a large attachment (or attachments) using SingleEmailMessage. A EmailFileAttachment[] List is created to contain the attachments which are within the 10mb limit for all attachments but when the attachment(s) exceed 2mb in size the Apex heap size limit is exceeded. There's obviously something I'm missing here. With this in mind, how are files, of up to 10mb collectively, attached to an email using the setFileAttachments method without exceeding the Apex heap size limit?

 

There's no problem uploading a file of up to 5mb in size to the Attachments object for example, that doesn't cause a Apex heap size error. So I assume blobs don't count against heap size. But that doesn't seem to be true for a collection of objects that contain a blob. Surely the blob is only held by reference?

 

The code below doesn't enforce the 10mb attachments limit but assume it's not exceeded. When fileAttachments exceeds 2mb the 'System.Exception: Apex heap size too large' occurs.

 

// Create EmailMessage and assign parameters
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Support');
mail.setSubject('New Case Created : ' + case.Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');
mail.setTargetObjectId(case.contactId);
mail.setWhatId(case.Id);

// Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength
from Attachment
where ParentId = :case.Id])
{
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);

// Send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })

Message Edited by nelloC on 02-16-2010 03:35 AM
  • February 10, 2010
  • Like
  • 0

I have an apex:commandLink which has an attribute of immediate="true". The link is used to display a yui modal dialog. I want to take the latest input from a field on the form to use as a search argument in the dialog but with the attribute immediate="true" any new input is not available at the server side. Is there a way of getting the latest input from a form field when using a commandLink (or button for that matter) with immediate="true".

 

 

 

  • January 03, 2010
  • Like
  • 0

Don't know when this stopped working but it was working and now not. I have the following code:

apex:tab label="Contacts" name="contactList">
<apex:pageBlock title="Contacts" id="contact_list">
<apex:pageBlockTable value="{!RelatedContactsList}" var="CO">
<apex:column headerValue="Action">
<apex:commandLink action="{!DeleteDLContact}" reRender="contact_list" onclick="window.confirm('Are you sure?');">
<b>Del</b>
<apex:param name="dlcontactid" value="{!CO.Id}" assignTo="{!DeleteDLContactID}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!CO.Contact__r.LastName}, {!CO.Contact__r.FirstName}" headerValue="Name"/>
<apex:column value="{!CO.Contact__c}"/>
<apex:column value="{!CO.Contact__r.Email}"/>
<apex:column value="{!CO.Contact__r.AccountId}"/>
</apex:pageBlockTable>
<apex:outputLink value="/apex/DistributionListContacts?dl={!id}" rendered="{!ContactListHasMore}">Show more »</apex:outputLink>
</apex:pageBlock>
</apex:tab>

When "Del" link is clicked the action method "DeleteDLContact" is called not matter whether OK or Cancel is clicked on the "Are you sure?" confirmation.

I have tried changing the onclick to onclick="return window.confirm('Are you sure?');"  but this results in the action method not being called at all. This definately was working, I can't work out what has changed to stop it working.

 

Any ideas? Thanks.

Message Edited by nelloC on 12-13-2009 03:57 AM
  • December 13, 2009
  • Like
  • 0

Send an Email can be overridden from Admin>App Setup>Activities>Activity Buttons with an s-control. This overrides the Send an Email button as well as the Reply and Reply To All links on the email related list. Does anyone know how to identify within the overriding s-control which email/activity was clicked when a reply link is clicked. There doesn't seem to be any relevant merge fields but I assume, seeing as the email related list reply links are overridden, that there must be a way to identify which item in the list was actually clicked.

 

Any ideas?

  • December 10, 2009
  • Like
  • 0

I need a javascript function that I can call from within a visualforce page that will make a call out to an external web service and return the result. The reason for this is that the result needs to be passed back to a calling javascript method rather than being rendered on the page.

What's the best way is acheive this?

- By using actionFunction and calling the actionFunction method from my proposed javascript method. I have attempted this option and the call out from the apex class method works fine but I'm not sure how to return the result to the calling javascript method. (i.e. I have a javascript method calling the actionFunction js method, passing in appropriate parameters, but unable to receive back a result.)

- Or by using Ajax Proxy? But was this designed for use within s-controls?

- Or any other suggestions gratefully received..

Message Edited by nelloC on 11-29-2009 12:28 PM
  • November 29, 2009
  • Like
  • 0
Is there a way of knowing within apex code whether Compliance Bcc Email has been enabled or not? In order to appropriately allow (or not) users to select a bcc email address when sending an email.
  • November 24, 2009
  • Like
  • 0

Are enum's allowed in inner classes? I'm getting a Save error: unexpected token: 'enum'

Can't find anthing that suggests they're not...

// Inner classes

class FromAddressItem {

public enum AddressType {TYPE_A, TYPE_B, TYPE_C}

public FromAddressItem (string type_In, string emailAddress_In, string displayName_In) {
AddressType = type_In;
EmailAddress = emailAddress_In;
DisplayName = displayName_In;
}

// Class properties

public string AddressType { get; private set; }

public string EmailAddress { get; private set; }

public string DisplayName { get; private set; }
}

Any ideas?

 

 

 

Message Edited by nelloC on 11-22-2009 04:35 AM
  • November 22, 2009
  • Like
  • 0

I would like to place a lookup button (a commandlink with an icon) to the right of an inputtext field. The field and it's label are within a pageBlockSectionItem. When I attempt to place link to the right of the inputtext field I obviously get the error: <apex:pageBlockSectionItem> may have no more than two child components.

Is there any way of placing a link to the right of this field or must I abandon the pageblocksection?

 

The field in question...

 

<apex:pageBlockSectionItem> <apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/> <apex:inputText value="{!ToContactName}" id="to_contact"></apex:inputText> </apex:pageBlockSectionItem>

 Would like to do this...

 

<apex:pageBlockSectionItem> <apex:commandLink value="To" id="to_contact_link" immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"/> <apex:inputText value="{!ToContactName}" id="to_contact"></apex:inputText> <apex:commandLink immediate="true" action="{!InitContactDialog}" reRender="contact_dialog_form"> <apex:image value="{!$Resource.SearchIconA}"/> </apex:commandLink> </apex:pageBlockSectionItem> 

 

 

 

  • November 03, 2009
  • Like
  • 0

I have built a custom VF form to send an email and I'd like to build in the same template functionality as is found on the Salesforce Send an Email form. i.e. the abilty to select a template, resolve the merge fields and place the resulting text in an email body text field on the form.

 

Does anyone know if it's possible to resolve an email template in this way? Or equally, can anyone confirm that it's not possible.

 

Thanks

  • October 26, 2009
  • Like
  • 0

I have a couple of columns in a pageblocktable that have a headervalue specified. When there are no records to display in the table the headervalue is still rendered in the header whereas the default header labels from an object field do not display. In my example below, "Action" and "Name" remain visible in the header when no records are displayed:

 

<apex:pageBlockTable value="{!RelatedUsersList}" var="US">

<apex:column headerValue="Action">
<apex:commandLink action="{!DeleteDLUser}" reRender="user_list" onclick="window.confirm('Are you sure?');">
<b>Del</b>
<apex:param name="dluserid" value="{!US.Id}" assignTo="{!DeleteDLUserID}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!US.User__r.LastName}, {!US.User__r.FirstName}" headerValue="Name"/>
<apex:column value="{!US.User__c}"/>
<apex:column value="{!US.User__r.Email}"/>
</apex:pageBlockTable>

 

Is there a way of dealing with this to prevent the header values from displaying when the table is empty? It looks rather messy when the field labels are not displayed but any header values specified are still visible.

Message Edited by nelloC on 10-22-2009 08:38 AM
  • October 22, 2009
  • Like
  • 0

I am trying to create an OrgWideEmailAddress in apex (via an insert in a testmethod) but I'm getting the message "Save error: DML not allowed on OrgWideEmailAddress" on compile. Any ideas on why this create is not being allowed? The OrgWideEmailAddress object specifies supported calls of: create(), delete(), query(), retrieve(), update().

 

 

OrgWideEmailAddress newOwea1 = new OrgWideEmailAddress(Address='testOwea1@test.com',DisplayName='TestOwea1');
OrgWideEmailAddress newOwea2 = new OrgWideEmailAddress(Address='testOwea2@test.com',DisplayName='TestOwea1');
insert newOwea1;
insert newOwea2;

 

 

 

  • October 19, 2009
  • Like
  • 0

We have recently raised a case with Salesforce support because our app is failing on installation. From the little information I have got back from support it seems to be failing on instantiating an innerclass. See below:

 

UtilityClass.ResolvedTemplate resolvedTemplate = new UtilityClass.ResolvedTemplate();

 Where the inner class is as follows:

 

public with sharing class UtilityClass {
...
... ... // Inner classes public class ResolvedTemplate { public ResolvedTemplate () { Subject = ''; Body = ''; TemplateAttachments = new List<Attachment>(); } public string Subject { get; private set; } public string Body { get; private set; } public List<Attachment> TemplateAttachments { get; private set; } } ... ... }

The app installation failed with the following message:

Your requested install failed. Please try this again.
None of the data or setup information in your salesforce.com organization should have been affected by this error.
If this error persists, contact salesforce.com Support through your normal channels and reference number: 1043502955-384 (-1811678545)

 

We're told by support the following error occurred on installation:

[DeployMessage] FAILURE problem: Invalid type: UtilityClass.Reso= lvedTemplate fullName: EmailAuthorController id null fileName: classes/Emai= lAuthorController.cls lineNumber: 1070

 

My problem is this. We have been informed that our case has identified a bug but as yet they haven't told us what the bug is. We're working on trying to get that information. But in the meantime has anyone else experienced this bug possibly? Or experienced a similiar problem? Or have any useful information on this issue? At the moment our app is uninstallable and we're completely in the dark as to what the bug actually is. If I can get some information on the bug we can probably find a work around until the fix is available. I thought its worth a shot posting it on here just in case anyone else has experienced the same problem.

 

Thanks

 

 

 

I'm sending an email with attachments using SingleEmailMessage. An EmailFileAttachment[] List is created to contain the attachments which are within the specified 10mb limit for all attachments but when the attachments exceed 2mb in size the Apex heap size limit is exceeded.

 

My question simply is this: how are files, of up to 10mb, attached to an email using the SingleEmailMessage class without getting 'System.Exception: Apex heap size too large'?

 

 

// Create EmailMessage and assign parameters
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Support');
mail.setSubject('New Case Created : ' + case.Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');
mail.setTargetObjectId(case.contactId);
mail.setWhatId(case.Id);

// Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength 
                     from Attachment
                     where ParentId = :case.Id])
{
  // Add to attachment file list
  Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
  efa.setFileName(a.Name);
  efa.setBody(a.Body);
  fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);

// Send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })

 

I came up against this issue a couple of months back, posted it, but got no response. So apologies, I'm posting again in the hope that I can finally find a solution.

 

Would appreciate any responses on this one, even if it's half a guess. Thanks in advance.

SingleEmailMessage
  • April 09, 2010
  • Like
  • 0

Hi Folks,

 

Requirement: To create a Schedule/Cron/Code job which executes after a specific interval, say after every 1 minute.

 

There is no direct feature in SFDC of doing it but with a tricky way.

Step 1: Create an Apex class which contains the business logic which is required to be executed after specific intervals.

Step 2: Create a Scheduleable Apex Class Like below:

 

global class ScheduleChatter implements Schedulable {
    global void execute(SchedulableContext SC)  {                 

        //The line of code below would contain the required business logic

        TestChatter.initGoogleApp();

        System.debug('-----------ScheduleChatter---------');

        String hour = String.valueOf(Datetime.now().hour());

        String min = String.valueOf(Datetime.now().minute() + 1);

        String ss = String.valueOf(Datetime.now().second()); 

        
String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

        System.debug('-----------nextFireTime---------' + nextFireTime);

        

ScheduleChatter s = new ScheduleChatter();

         System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);

        

}   

}

 

Step 3: This Schedule job is initiated by a code, which can be run on System log screen or via another trigger/class:

ScheduleChatter s = new ScheduleChatter();

String hour = String.valueOf(Datetime.now().hour());

String min = String.valueOf(Datetime.now().minute());

String ss = String.valueOf(Datetime.now().second());

String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';

system.schedule('Start me once', nextFireTime, s); 

 

The Schedulable class will keep on calling itself after every 1 minute and eventually calls the code which is needed to be called after specified interval of time.

 

This code is written as part of R&D.

 

Thanks,

Sam

I'm getting the following error when trying to upgrade a managed package into our test org:

 

Your requested install failed. Please try this again.
None of the data or setup information in your salesforce.com organization should have been affected by this error.
If this error persists, contact salesforce.com Support through your normal channels and reference number: 497370194-3524 (-459893822)
 
A new install though, completes without error.
 
I've filed a support case # 03397794
 
Thanks
Message Edited by nelloC on 03-17-2010 02:39 PM
  • March 17, 2010
  • Like
  • 0

I have a dynamic soql statement like this for example:

 

Sobject relObj;
relObj = Database.query('Select Id, ns__user__c, ns__Distribution_List__r.Name from ns__Distribution_List_User__c where id = \'a0aA0000000aaAAAAA\'');
String listName = String.valueOf(relObj.get('ns__Distribution_List__r.Name'));

Which is retrieving a parent relationship name field.
The query runs fine but the get() fails: Invalid field. It doesn't recognise 'ns_Distribution_List__r.Name'.
How is the parent relationship name field data retrieved?

 

Thanks

 

Message Edited by nelloC on 03-09-2010 08:40 AM
  • March 09, 2010
  • Like
  • 0

I'm attempting to send an email with a large attachment (or attachments) using SingleEmailMessage. A EmailFileAttachment[] List is created to contain the attachments which are within the 10mb limit for all attachments but when the attachment(s) exceed 2mb in size the Apex heap size limit is exceeded. There's obviously something I'm missing here. With this in mind, how are files, of up to 10mb collectively, attached to an email using the setFileAttachments method without exceeding the Apex heap size limit?

 

There's no problem uploading a file of up to 5mb in size to the Attachments object for example, that doesn't cause a Apex heap size error. So I assume blobs don't count against heap size. But that doesn't seem to be true for a collection of objects that contain a blob. Surely the blob is only held by reference?

 

The code below doesn't enforce the 10mb attachments limit but assume it's not exceeded. When fileAttachments exceeds 2mb the 'System.Exception: Apex heap size too large' occurs.

 

// Create EmailMessage and assign parameters
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Support');
mail.setSubject('New Case Created : ' + case.Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');
mail.setTargetObjectId(case.contactId);
mail.setWhatId(case.Id);

// Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength
from Attachment
where ParentId = :case.Id])
{
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);

// Send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })

Message Edited by nelloC on 02-16-2010 03:35 AM
  • February 10, 2010
  • Like
  • 0

I have an apex:commandLink which has an attribute of immediate="true". The link is used to display a yui modal dialog. I want to take the latest input from a field on the form to use as a search argument in the dialog but with the attribute immediate="true" any new input is not available at the server side. Is there a way of getting the latest input from a form field when using a commandLink (or button for that matter) with immediate="true".

 

 

 

  • January 03, 2010
  • Like
  • 0

Don't know when this stopped working but it was working and now not. I have the following code:

apex:tab label="Contacts" name="contactList">
<apex:pageBlock title="Contacts" id="contact_list">
<apex:pageBlockTable value="{!RelatedContactsList}" var="CO">
<apex:column headerValue="Action">
<apex:commandLink action="{!DeleteDLContact}" reRender="contact_list" onclick="window.confirm('Are you sure?');">
<b>Del</b>
<apex:param name="dlcontactid" value="{!CO.Id}" assignTo="{!DeleteDLContactID}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!CO.Contact__r.LastName}, {!CO.Contact__r.FirstName}" headerValue="Name"/>
<apex:column value="{!CO.Contact__c}"/>
<apex:column value="{!CO.Contact__r.Email}"/>
<apex:column value="{!CO.Contact__r.AccountId}"/>
</apex:pageBlockTable>
<apex:outputLink value="/apex/DistributionListContacts?dl={!id}" rendered="{!ContactListHasMore}">Show more »</apex:outputLink>
</apex:pageBlock>
</apex:tab>

When "Del" link is clicked the action method "DeleteDLContact" is called not matter whether OK or Cancel is clicked on the "Are you sure?" confirmation.

I have tried changing the onclick to onclick="return window.confirm('Are you sure?');"  but this results in the action method not being called at all. This definately was working, I can't work out what has changed to stop it working.

 

Any ideas? Thanks.

Message Edited by nelloC on 12-13-2009 03:57 AM
  • December 13, 2009
  • Like
  • 0

Send an Email can be overridden from Admin>App Setup>Activities>Activity Buttons with an s-control. This overrides the Send an Email button as well as the Reply and Reply To All links on the email related list. Does anyone know how to identify within the overriding s-control which email/activity was clicked when a reply link is clicked. There doesn't seem to be any relevant merge fields but I assume, seeing as the email related list reply links are overridden, that there must be a way to identify which item in the list was actually clicked.

 

Any ideas?

  • December 10, 2009
  • Like
  • 0

Is it possible to delete list custom settings records in code?  I'm getting an "invalid cross reference id" when I attempt to do this as part of a test.

 

Reason I'm doing this: the code I'm working on will be packaged and distributed to various clients.  It uses a list custom settings object to enable each client to use their own parameters.  But for the tests, I need to know what the parameters are so I know what to test for.  Since I can't know what the client will have put in for their custom settings, safest bet in the test is to delete whatever settings exist, and then replace them with  standard ones.

 

It's letting me insert new settings, but not delete existing ones.

  • December 04, 2009
  • Like
  • 0

I need a javascript function that I can call from within a visualforce page that will make a call out to an external web service and return the result. The reason for this is that the result needs to be passed back to a calling javascript method rather than being rendered on the page.

What's the best way is acheive this?

- By using actionFunction and calling the actionFunction method from my proposed javascript method. I have attempted this option and the call out from the apex class method works fine but I'm not sure how to return the result to the calling javascript method. (i.e. I have a javascript method calling the actionFunction js method, passing in appropriate parameters, but unable to receive back a result.)

- Or by using Ajax Proxy? But was this designed for use within s-controls?

- Or any other suggestions gratefully received..

Message Edited by nelloC on 11-29-2009 12:28 PM
  • November 29, 2009
  • Like
  • 0
I'm seeing this (all by itself) in a debug log. What does it mean? And why does it claim to take 9,136 ms? And why is there another debug log, immediately following, and resulting from the same (single) click, but with a start time only three seconds later?

Element thePage called method {!checkManageability} returned type PageReference: none

I'm getting the following error with IE in the Salesforce javascript supporting Ajax calls ....

 

 

Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Wed, 23 Sep 2009 02:00:43 UTC Message: Unknown runtime error Line: 120 Char: 1 Code: 0 URI: http://homewarrantygroup.force.com/faces/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript

 



 

 

The page is hosted in an iFrame and works perfectly in Firefox, but when I click an actionButton in IE, the Ajax callback starts (but doesn't finish) and IE shows this error in the alerts area.

 

Has anyone else run into this error?  Is there a fix?

 

Thanks,

Ron 

I like to include a link to my salesforce record in an outbound  Messaging.SingleEmailMessage email, but I don't want to include a hard code instance as outlined in the documentation. How do I get the salesforce instance na1, na2, na3,... that I am working on. Pagereference getURL() only returns a partial URL.

 

From the documentation:

 

 http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_classes_email_outbound.htm|SkinName=webhelp

 

mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+
' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');

 

Thanks,

 

Matt

I'm trying to format an address field for display in a VF email template and haven't found a way to replace line feeds/carriage return with an html tag.

 

I'd like to do it within the template, but if I have to create a formula field and merge that field I will.

 

SUBSTITUTE( PDS__Shipping_Address__c ,BR(),'<br/>')   .... doesn't seem to find the line feeds.

 

SUBSTITUTE( PDS__Shipping_Address__c ,CHR(13),'<br/>')   .... rejects CHR() as an unknown function.

 

Besides writing a trigger to do this in Apex, is there another solution?

 

 

Hi,
I am sending emails through my Apex class(NOT VisualForce APEX class). The text body of EMail contains the hyperlink to one of my Visualforce page. But depending on the Salesforce account type the instance name in the URL changes.(Example: https://cs2.salesforce.com/apex/myTimeSheets).

In above case cs2 can be na1 or na2 depending on instance type.
Is there any method in APEX by which I can get the name of the SF instance?
This is very simple in SControl but I am not getting anything in Apex fopr the same.