• Kirk F.ax361
  • NEWBIE
  • 75 Points
  • Member since 2008

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 31
    Replies

I want to convert a decimal to a string and force a certain format,  someting analogous to "##0.00" with the DecimalFormat class in Java.

 

If I use the format method, there's no control of the form.  When the value is 0, I get "0" whereas I want "0.00".

 

 

Is there any formatting facilty in Apex?

 

This is for going input a VF page but it's not an SObject field so I can use OuputField.

 

I was wondering how I can use a custom controller with a class variable, totalAmount, defined as a Double data type and have it displayed as a Currency field in a Visualforce Page? I know if I use a standard controller and use component that Visualforce will automatically render it as a currency field. But how do I accomplish that with a custom controller and a class field defined as a "Double" data type?

To elaborate, the scenario is to display the total amount of multiple line items. The visualforce page allows users to enter multiple lines items with varying amounts and at the bottom there is the "Total" amount. The VF/Apex code is properly aggregate the amount, but it is stored as a Double data type field in the Apex Code controller class - and therefore displayed in the page as a double.


Thanks.

Message Edited by Drew1815 on 04-14-2008 11:33 AM

Does anyone know why the following query line:

List<Contact> contacts = new List<Contact> ([Select Id, Email from Contact where IsPersonAccount = false]);

Yields this error message:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger LeadAssignmentFromImagitas caused an unexpected exception, contact your administrator: LeadAssignmentFromImagitas: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.LeadAssignmentFromImagitas: line 18, column 9

?

The query returns only 58 rows.

Any help is greatly appreciated.  Thank you.
  • February 19, 2008
  • Like
  • 0

I'm developing an application that contains multiple custom objects whose records function as more or less static data that is looked up in another custom object by the user.

 

I'm talking accounts, currencies etc except there are around 10 custom objects in all.

 

I want to have a single page that lets me select the custom object type from a drop down and display something similar to the default controller's list view.

 

So far, I've just been showing and hiding blocks of html to achieve this result but it's not really an ideal way of doing this in terms of code reuse. Is there any more generic way I can display info about multiple custom objects on a single page?

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 all, 

 

i'm trying to use Rich Text Field on a Salesforce site's page with a custom controller. 

I updated both the controller and Visualforce page version at 18.0 :

 

- the controller, after this save, works correctly 
- but when i try to saving the version of this visualforce page, the error will appear is: 
"Error: Invalid field Description__c for SObject Ospitalita__c" 
(Description__c is the Rich Text Field) 


For your info, if i insert this rich text field in a empty visualforce page, it works correctly. 
But i give the error in my site pages , which have the template tags (apex:composition and apex:insert) . 

Are "this tags" the problem? 

How can i fix it? 
I need apex:composition and apex:insert and i don't want to delete them or substitute with component.

 

Thanks in advance!! 

Hello,

 

I wish to know using the excel connector or Apex Data Loader is there a way to filter records that do have an attachment attached to it for either a custom or standard object and if it was a boolean what field would I be looking at?

Basically I want to know how many records I extract using either the excel connector or Apex Data Loader that does have a document attached to it and if possible how many attachments if there is more than one.

 

Thanks

 

  • March 04, 2010
  • Like
  • 0

Is there any way to change or delete a Scheduled Job ?  I am able to create one easily enough, but once it is made I can only look at the values in the CronTrigger object, but not update them.  Also, it seems I cannot delete them.  I also looked at the System.AbortJob method, but that seems to only stop a job that is already running - I get an error if I try it on a Queued job.

 

The reason I am doing this is to try to create a 'sliding' job.  So, when a trigger is fired the job will run in 5 minutes.  But if the trigger is fired again before that 5 minutes is up, it will find the old job and either delete it and make a new one for 5 minutes out, or update the old one so the next scheduled time is in 5 minutes.

 

Any ideas are welcome!

 

Jason

 

 

Hey guys

 

I am trying to debug an issue with deploying files to a production instance.  In doing so, I want to run a single test class in order to examine the debug log.

 

However, when I do Force.com -> Run Tests on the test class that I want, the debug log shows the log for all unit tests for some reason.  Because of this, the log quickly is filled up and is truncated with the note:

 

*********** MAXIMUM DEBUG LOG SIZE REACHED ***********

... and therefore I am unable to see the log for the test class that I selected.

 

How can I run a single test class in a Production environment so that I can view log for just that class?

I'm trying to disable a commandButton on my VF page on click because I'm invoking a possibly long running action in my controller (10 seconds or more), and I wish to prevent the user from clicking the button again, and double submitting. I tried doing this using a simple javascript onclick function that disables the button and returns true. This doesn't work because once I disable the button in javascript, the action method doesn't get invoked in my controller. Any other suggestions?

  • October 29, 2009
  • Like
  • 0

I have a Sites page that dynamically generates a PDF from a custom CMS. As part of that page, I would like to dynamically include certain images throughout, accessed from Static Resources, in sections of HTML generated by the Apex Controller through the use of <apex:outputText value="{!someGetter}" escape="false" />.

 

If the page is not set to renderAs="pdf", I can access Static Resource images in the return value of the Apex method like this:

 

return '<img src="resource/ResourceName">';

 

However, if I set renderAs="pdf" so that the page renders as PDF, the images show up broken. I've tried a few different ways of accessing the Static Resource, including the full URL, as well as linking to images off-site, like the Google Logo. I've even tried embedding the image into the text, using Base64. It seems like the only way to include an image in a PDF is to have it directly in the VisualForce page, which is inconsistent with the rendering of a regular VF page. Is this a bug, or is there some way to accomplish what I'm trying to do here?

 

Thanks,

Tom

I want to convert a decimal to a string and force a certain format,  someting analogous to "##0.00" with the DecimalFormat class in Java.

 

If I use the format method, there's no control of the form.  When the value is 0, I get "0" whereas I want "0.00".

 

 

Is there any formatting facilty in Apex?

 

This is for going input a VF page but it's not an SObject field so I can use OuputField.

 

On a standard Salesforce edit page, when the save button is clicked, the button immediately grays out and prevents the user from clicking the button multiple times.  I'm trying to get the same effect on a VFP but I am having no luck.  Has anybody already done this?  I don't know if it's pertinent, but my save button is calling a method called Save in a custom controller.

 

 

<apex:pageBlockButtons > <apex:commandButton action="{!Save}" value="Save" id="saveBtn" /> </apex:pageBlockButtons>

 

 

 

  • March 02, 2009
  • Like
  • 0

Is there a way to do this?

 

I have several VisualForce pages I am using the generate PDF documents.  I find that I cannot seem to control simple layout and style items, such as the format for table headers and the type of font used for the document, using in-line CSS when these pages render as PDFs.  I am easily able to control these elements using in-line CSS when I render these pages as HTML.

 

This is important as several VisualForce elements do not let me define style attributes for an element. I have to use in-line CSS classes to pass to the element's appropriate 'style' attribute.  An example of this is the 'apex: DataTable'element, which requires I pass it a CSS class to the 'headerClass' and 'rowClasses' attributes.

 

However, it is as if the PDF rendering engine is ignoring my in-line CSS.  Is there any way to force the PDF engine to use my CSS, so I can get a PDF output which matches my HTML output?

Message Edited by m_roark on 02-20-2009 09:14 AM

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

 

Hi,

I am using the OpportunityLineItem.TotalPrice field in one of my VisualForce pages with the Standard 'Opportunity' controller.  We are preparing a sort of quote document with the line items and amounts from an Opportunity.  I am using the 'outputField' tag to show this field.  Simplified version of the code below:

Code:
<apex:dataTable value="{!opportunity.OpportunityLineItems}" var="Item" width="675" rules="all" cellPadding="6" styleClass="data" columnClasses="info_bottom_1, info_bottom_2, info_bottom_3, info_bottom_4">
            <apex:column>
                 <apex:outputField value="{!Item.TotalPrice}"/>
            </apex:column>
   </apex:dataTable>

 
Since our organization has multi-currency turned on, the values coming from the 'TotalPrice' field have the ISO code as well as the value, and do not have a Currency Symbol.  For example, this is shown as:

USD 47,250.00


However, we would like to show this value as:

$47,250.00



Is there some way to have Salesforce return the value in this format?   Can this be done across currencies ?

Or, does someone have a good suggestion for doing a sort of  'replace' function so that I can replace the ISO code with the currency symbol for our currencies??

Many thanks for any ideas.




I am trying to automatically submit a record for approval in a visualforce page but hitting some problems.  I tried following the Apex Approval Processing example (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm) but I get this error:

Code:
System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval 
process found.

 
So I thought I needed to create a ProcessInstance but trying to insert this results in:

Code:
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, 
Required fields are missing: [ProcessDefinitionId, CurrentNodeId]: [ProcessDefinitionId, CurrentNodeId]

 
I have set up an approval process for my custom object and it is active so that doesn't seem to be the problem.  This is a controller extension for my VF page and the 'record' variable is the object that has been passed into the page.  Here is my function that uses the submit for approval :

Code:
public void SubmitApproval()
    {
/* Attempting to set up a ProcessInstance
ProcessInstance approvalProcess = new ProcessInstance(); approvalProcess.TargetObjectId = record.Id; //approvalProcess.ProcessDefinitionId = ; approvalProcess.Status = 'Started'; //approvalProcess.CurrentNodeId = ; //insert approvalProcess;
*/

// Create an approval request
  Approval.ProcessSubmitRequest approvalRequest = new Approval.ProcessSubmitRequest(); approvalRequest.setComments('Testing Approval Submit'); approvalRequest.setObjectId(record.Id); Approval.ProcessResult approvalResult = Approval.process(approvalRequest); if (!approvalResult.isSuccess()) { ApexPages.Message error = new ApexPages.Message(ApexPages.Severity.ERROR, 'There was an error with the Submit For Approval Request.'); ApexPages.addMessage(error); } }

 
Edit:  Just a quick update.  If I submit the record for approval using the normal way I can then create a commandButton that approves the pending request.  This approval doesn't run into any problems at all.  I must be missing something from my Submit request.






Message Edited by XactiumBen on 06-24-2008 03:21 AM

Message Edited by XactiumBen on 06-24-2008 03:50 AM
I'm creating cases through the api.  We have an auto-response rule that we would like to fire, but it's not throwing any email.  I look in the debug log and it says the rule evaluated to true. 
 
Rule entry order: 2
[Case : Functional Area equals Website Change Request]
AND [Case : Case Origin equals Website]
Value found: 14
Value found: Website
Criteria evaluates to true
Spooling All Immediate Actions
[Case: 20285 50060000004GMZ5]
  Response notify: Bill Brasky, Email: sxxxxxx@xxxxxxxxxxxxxx.com
  Template: 00X60000000wKv8
Nothing is going out.   Any thoughts??
 
Hi,
We use the Excel Connector to update Opportunity records with quote values from an estimation spreadsheet.  It has worked fine for about 4 months but now won't update numeric fields.  Dates, currency and text all still work fine.
 
Any ideas?
 
Thanks.
  • February 21, 2008
  • Like
  • 0