• jgrenfell
  • NEWBIE
  • 105 Points
  • Member since 2007

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 40
    Replies

If I anticipate uploading 1000+ records at once, do I need to have my triggers ready to process bulk records?

 

Ben

HI,

 

I have written a controller, and a page that uses it. This method catches an exception, I am trying to pass the error to the apex : messages visualforce page .

 

Clicking Running this method, I get an "An unexpected error has occurred.  " page. what's wrong with my exception catching?

 

 

public void deleteOldInvoices() {

//this method is in the controller. it is run from the page try { //some code here. } } catch (Exception e) { Apexpages.addMessages(e); } }

 

 Thanks

Ben 

 

Hi, I'm a newbe to Apex and am running into some issues with a trigger. The problem is that I am trying to update a list but I am receiving this error below

 

 

Error:Apex trigger Update_Opp_Amounts caused an unexpected exception, contact your administrator: Update_Opp_Amounts: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006S0000003BqedIAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Update_Opp_Amounts: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006S0000003BqedIAC; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006S0000003Bqed) is currently in trigger Update_Opp_Amounts, therefore it cannot recursively update itself: [] Trigger.Update_Opp_Amounts: line 26, column 9: []: Trigger.Update_Opp_Amounts: line 26, column 9 

 

 

My code

 

 

trigger Update_Opp_Amounts on Opportunity (before insert, before update)
{
    List<Opportunity> Opp= Trigger.new;
    List<String> OppOwner =  new List<String>();
   
    for (Opportunity Oppy:Opp)
    {
        OppOwner.add(Oppy.OwnerID); 
    }
   
    List<Opportunity> OppAmounts = [SELECT Amount, Total_Pipe_Line__c FROM Opportunity WHERE
                        StageName not in('Closed Lost', 'Order Received') and ownerID IN :OppOwner]; 
   
    decimal total_amount = 0.0;
    decimal amounts = 0.0;
   
    for (Opportunity OppUpdate:Opp)
    {
        for (Opportunity OppAmnts:OppAmounts)
        {
            amounts = OppAmnts.Amount;
            total_amount += amounts;
            OppUpdate.Total_Pipe_Line__c = total_amount;
        }
        OppUpdate.Total_Pipe_Line__c = total_amount;

        Update OppAmounts    //problem here with the update
    }     
}

 

As my code suggests I would like to try and update ALL records in OppAmounts list and not just update on the current record. Does any one have any suggestions on how to do this please?

I can access both Holidays and Business Hours, but I'm wondering where to find the junction table between the two.  I'm writing code where I'd like to access only the Holidays that are associated with the Business Hours marked as default and I'm not seeing it.  Any help would be appreciated.

Hello,

I am using a soql query to retrieve records from contact.

Here is my query:

List<contact> contactList=[Select name,Email from contact where id=:contactId];

 

I am able to execute this if i have less records but if i have more records that is fr about 200 Records i am getting an exception:

Too many SOQL queries: 101 .

 

When i looked for this Exception  i came to know that a database statement cannot process more than 100 records. 

 

Is there any method to overcome this issue please help me out with code if any.

 

Please help me out of this issue.

 

Thanks in advance,

prashanth. 

 

 

I've built a simple Visualforce page used to compose emails, using an inputTextArea with richText = true for the body of the email.  The problem is, anytime you hit enter while in that inputTextArea, instead of adding a line break it submits the form (i.e. sends the email).  I've tried setting the form to immediate = false, and adding an actionSupport for the onenter event with no action, but it still happens.  Anyone know how to get around this?  The page is below.

 

 

<apex:page standardController="Contact" extensions="extEmailPO2"> <apex:form id="editorForm"> <apex:pageBlock id="pageEmail"> <apex:pageBlockButtons > <apex:commandButton action="{!send}" value="Send" id="theButton" immediate="false"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > To: <apex:outputText value="{!POEmail}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Subject: <apex:inputText id="subject" value="{!eSubject}" required="true" style="width: 400px"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:inputTextarea id="email" richtext="true" value="{!eContent}" required="true" > <apex:actionSupport event="onenter"/> </apex:inputTextarea> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

I have page with a custom controller and a tab panel.  In one of the tabs, I want the user to be able to flip between a view to enter a new record and a list of historical records.  I'm using a boolean variable to track which form (new or historical) should be rendered and a commandlink to set that variable.  Every time I click on that commandLink though, the new form remains with the "You must enter a value" error on the required fields in the form.  I don't want that form saved though and can't seem to get around.  I've tried filling in those fields and then hitting the commandlink, but the same thing happens.  What am I missing?

 

Code for that tab:

 

<apex:tab id="tabFLSEReferral" label="FLSE Referral" rendered="{!IF(student==null, false, true)}"> <apex:form id="formFLSEReferral" rendered="{!modeNewFLSERef}"> <apex:commandLink action="{!linkFLSENewRef}" rerender="formFLSEReferral, formFLSEReferralHistory" value="{!IF(modeNewFLSERef, 'View Referral History', 'Enter New Referral')}" style="font-weight:bold;font-color:#0000ff;font-size:12" /> <apex:pageBlock id="pageFLSEReferral" rendered="{!modeNewFLSERef}"> <apex:pageblockButtons ><apex:commandButton action="{!save_flseReferral}" value="Save"/></apex:pageblockButtons> <!-- NEW / EDIT --> <apex:pageBlockSection columns="2"> <apex:pageBlockSectionItem > Referral?: <apex:inputField value="{!flseRef.Referralcheckbox__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Referred By: <apex:inputField value="{!flseRef.Referred_By__c}" required="true" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Referral Date: <apex:inputField value="{!flseRef.Referral_Date__c}" required="true" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <!-- HISTORICAL RECORDS --> <apex:form id="formFLSEReferralHistory" rendered="{!Not(modeNewFLSERef)}"> <apex:pageBlock id="pageFLSEReferralHistory" rendered="{!Not(modeNewFLSERef)}"> <apex:pageblockSection columns="1"> <apex:pageBlockSectionItem > <apex:pageBlockTable value="{!flseReferrals}" var="flseRef"> <apex:column headervalue="Action" > <apex:commandLink action="{!linkflseEditRef}" rerender="formFLSEReferral, formFLSEReferralHistory" value="edit"> <apex:param name="selectedId" value="{!flseRef.id}"/> </apex:commandLink> </apex:column> <apex:column headervalue="Profile" value="{!flseRef.Profile_Status_FLSE_notes__c}"/> <apex:column headervalue="Component" value="{!flseRef.Profile_FLSE_Component__c}"/> <apex:column headervalue="Created Date" value="{!flseRef.CreatedDate}"/> </apex:pageBlockTable> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:tab>

 Code for that commandLink (I added the clear method to try to avoid this, but to no avail):

 

public PageReference linkFLSENewRef() { this.modeNewFLSERef = (modeNewFLSERef ? false : true); if (!this.modeNewFLSERef){ this.flseRef.clear(); } return null; }

 

 

 

 

 

Is there a way to display items in a htmlBody of an email. I know it accepts only strings, but if there is a workaround to getting list items to display in the email, it would great.

 

Any suggestions?

 

thanks

 

cheers

sand

I have a number of classes and triggers with test methods that have all been functioning correctly for months.  There were certain (rare) cases where the SoQL Query limit was being hit, so to avoid this, I annotated one method as @future.  I then run the tests, and even though it's the exact same code as before just plus the @future, it's now returning "Too many SoQL queries" as an error.  In going through the debug logs, no single DML operation uses more than 20 queries (not even close), but cumulatively the inserts in the test method are hitting 21.  The cumulative limit for SoQL queries is supposed to be 100, not 20?

 

I can't possibly post all of the code behind this, but this is the test method itself.  The only thing that's changed from when it was working is that one of the methods called as a result is now @future and adding the startTest / stopTest - could that have an impact?  It hits the SoQL limit error on the last Event insert.  Anyone have any ideas?

 

 

static testMethod void testAdjournedCourtDateCheck() { Test.startTest(); Event event1; // Find the ID of the CEP Account Account CEP = [SELECT ID FROM Account WHERE Account.Name = 'CEP' and Account.RecordType.Name = 'CASES Programs']; // Create some sample dates for insert commands Date birthDate1 = Date.newInstance(1976,11,20); Date activityDate = Date.newInstance(2006,11,20); Datetime activityDatetime = Datetime.newInstance(2006,11,20); Date activityDate2 = Date.newInstance(2006,11,21); Datetime activityDatetime2 = Datetime.newInstance(2006,11,21); Date referDate1 = Date.newInstance(2006,11,20); Date intakeDate1 = Date.newInstance(2006,11,21); // Set the RecordTypes Id eventType = '012600000004yjw'; Id contactType = '012600000004zC5'; Id intakeType = '012600000004z70'; //Create a Test Client Contact testContact = new Contact(FirstName = 'Unit', LastName = 'Tester', AccountId = CEP.Id, Gender__c = 'Male', Birthdate = birthDate1, RecordTypeID = contactType); insert testContact; //Insert an Intake case for the client Case_Information__c cinfos_intake = new Case_Information__c(Client__c = testContact.Id, Name = 'test777777', Borough__c = 'X - Bronx', Referred_On__c = referDate1, Intake_Date__c = intakeDate1, RecordTypeID = intakeType); insert cinfos_intake; //Insert an adjourned Court Date Appointment Boolean IsError1 = false; try{ event1 = new Event( Outcome__c = 'Adjourned', Subject = 'Court Date', ActivityDate = activityDate, ActivityDateTime = activityDatetime, RecordTypeID = eventType, DurationInMinutes = 60, WhatId = cinfos_intake.Id ); insert event1; } catch(Exception e) { IsError1 = true; System.debug('The error is: ' +e); } //Insert another Court Date Appointment Boolean IsError2 = false; try{ event1 = new Event( Outcome__c = 'Pending', Subject = 'Court Date', ActivityDate = activityDate2, ActivityDateTime = activityDatetime2, RecordTypeID = eventType, DurationInMinutes = 60, WhatId = cinfos_intake.Id ); insert event1; } catch(Exception e) { IsError2 = true; } Test.stopTest(); //First event insert should go in System.assertEquals(false, IsError1); //Make sure Disposition Date being updated cinfos_intake = [Select Id, Court_Dates_After_Adjourned_Outcome__c from Case_Information__c where Id = :cinfos_intake.Id]; System.assertEquals(true, cinfos_intake.Court_Dates_After_Adjourned_Outcome__c); }//end testAdjournedCourtDateCheck

 

 

 

For those who use asynchronous apex what is your average time between when the job is submitted and it completes. The documentation says that these jobs will execute when system resources are available but from what I can tell they execute almost instantly after submission. I'm sure this is not a safe assumption, especially with batch processing coming, as this could definitely cause an increase in queue times.

So has anyone noticed a significant delay between aschrounous submission time and completion time?

Thanks,
Jason

Message Edited by TehNrd on 02-28-2009 04:58 PM

I'm creating a page that includes a list of Folders for email templates, and when the user selects a folder, I want to display the EmailTemplates in that folder.  I'm getting an error on the SoQL to do that though- "unexpected token : FolderId". The same query works fine in the Schema Explorer in Eclipse. 

 

 

List<EmailTemplate> ets = [Select Id, Name From EmailTemplate where FolderId := this.eFolder];

 

 Anyone have any ideas?

 

Hi

 

I am getting error while running test cases.

 

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>

 

Please help me its urgent

After getting all my tests running fine on Friday, I came in this morning to re-run after some changes to Apex classes. The sandbox was upgraded to Spring 09 on the weekend, and now every time I try to run any tests via Eclipse I get the nice "unknown exception" - unexpected error has occurred message.

 

I can run tests ok via the browser but this is not ideal for debugging.

 

Anyone else getting this after the Spring 09 upgrade? I am still coding using v14 of the API.

 

Thanks,

Stephen

I am receiving the following Apex Controller compile error message:
 
      Field is not writeable: Name.Name at line 17 column 38
 
Below is the code in question:

Code:
public class mySecondApexPageController { 

public String getMumbledpeg() { 
return ('Mumbledpeg'); 
} 

public List<EmailTemplate> getTemplates() { 
System.debug('Entering getTemplates() in mySecondApexPageController'); 
List<EMailTemplate> Results = 
[ SELECT Id, EMailTemplate.Name, Subject, TemplateType, FolderId, 
Folder.Name 
FROM EmailTemplate 
WHERE IsActive = true 
ORDER BY Folder.Name, EMailTemplate.Name ]; 
for ( EMailTemplate i : Results ) { 
if (i.Folder.Name==null) { i.Folder.Name = 'Unfiled Email Template'; } 
} 
return Results; 
} 
} 

 
My thinking was that the controller code did nothing to cause the field to be non-writeable, and there are not any programming facilities (that I know of) to make the field writable. BTW, I have also tried copying Results via the deepclone() method, but the cloned array is non-writable in this field also.  
 
That said, is there another methodology I can use to accomplish the desired goal of modifying the Results array contents prior to being returned by the getTemplates() method???
 
THanks in advance for your time and consideration. 
Hi all,
 
what's the advantage/disadvantage of using crystal report for SFDC DB?
 
 
Thanks.
I am trying to change the look of the using the style attribute. The problem is I can't find any documentation on the style attributes that the toolbar component uses.

In other words, the default appearance is a green-to-black gradient that looks terrible on my vf page.

What are the css properties that I can change to style the toolbar?
Hi,

I need to write a piece of code which will get the List of Opportunity difrentiated by some criteria and want to email those records every weekends.

Its like Time Based coading.

I have read about time dependent Workflow triggers but it doesnt resolves my problem because it does not provide flexibility to write the Apex code.

I want to run the code once in every week.

Can anyone give some suggestions?

Thanks in Advance!


I have an S-control that just takes the id that's passed to it (it's the Id of a new record just saved), performs a SoQL query and then redirects the user to a related record.  It works perfectly for system admins, but not for one of the users- it just sits there blank without redirecting.  I logged on as that user and was able to recreate the issue, which indicates this is something to do with permissioning. 

With some alert calls in the s-control, I was able to pinpoint that the javascript just stops when it tries to perform the SoQL query.  The user profile for this user has rights to the object being queried, has the API enabled and I tried adding a couple rights to the profile- View All Data and View Configuration, but to no end.  Is there a setting, in the profile or elsewhere, that would prevent a user from being able to run a SoQL query in an S-Control? 

I have similar s-controls in different salesforce instances and have never hit this before, very frustrating!