• stcforce
  • NEWBIE
  • 175 Points
  • Member since 2011

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 75
    Replies

I currently have this written which isn't working out because sometimes people reopen cases

trigger UpdateResoTCategor on Case (before update) {

  Double timeStat;
  BusinessHours bh = [select id from businesshours where isDefault = true];
  
  for (Case c : Trigger.new){
    Case oldCase = Trigger.oldMap.get(c.ID);
      
      if (oldCase.Status != 'Closed' && (c.Status == 'Closed' || c.Status == 'Escalated')){
        timeStat = BusinessHours.diff(bh.id, c.CreatedDate, System.now())/3600000.0;
           
        c.TimeBetweenCase__c = timeStat;    
      }    
  }
}

 I want to calculate the time difference between open and closed in BusinessHouses based on CreatedDateTime and ClosedDateTime but the problem is that isClosed and the ClosedDate don't actually get genereated til afterwards. I tried to do the same thing on after update and used the ClosedDate field but I keep getting errors on it: "execution of AfterUpdate caused by: System.FinalException: Record is read-only"

 

Does anyone have any ideas on how to do this?

 

  • August 10, 2012
  • Like
  • 0

I'm trying to pass a dynamic picklist from my controller to my page. I've successfully used this technique in the past, but now, I get the following message:  

 

Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.ApexELResolver$VisualforceArrayList 

 

This is triggered by  event="onchange"  action="{!getTeamMembers}" in the section of code associated with the "Sales Team" output label. 

 

The page code is: 

 

<apex:pageblockSectionItem >
     <apex:outputLabel value="Sales Team:" />
     <apex:selectList value="{!vChosenSalesTeam}" multiselect="false" size="1"  >
         <apex:selectOptions value="{!SalesTeams}"/>
         <apex:actionSupport event="onchange"  action="{!getTeamMembers}" rerender="USAT" />
     </apex:selectList>
</apex:pageblockSectionItem>

<apex:pageblockSectionItem >
    <apex:outputLabel value="Team Member:" for="TeamMembers"/>
    <apex:selectList id="TeamMemberList"  value="{!vChosenSalesPerson}" multiselect="false" size="1"  >
        <apex:selectOptions value="{!TeamMembers}"/>
    </apex:selectList>
</apex:pageblockSectionItem>

 

The controller is: 

 

    Public list<selectOption> getTeamMembers()
    {
       
       System.debug('#################### USAT_GD_ShareRefPageExtension MilePost getTeamMembers-0100'); 
     
       System.debug('#################### vChosenSalesTeam: ' + vChosenSalesTeam);  
       
       List<SelectOption> TeamMembers = new List<SelectOption>();
       
       TeamMembers.add(new SelectOption('- None -', '- None -')); 

           
       for (User UList : 
          [SELECT Id, Name
           FROM   User
           WHERE  Sales_Team__c = :vChosenSalesTeam
           AND    Sales_Team__c != null  
           AND    IsActive = true
           AND    AMS_Territory__c != null
           AND    Property__c in ('1531 - Republic Media', 'NST', 'USAT', 'USAT SPORTS', 'USA WEEKEND')   
           ORDER  BY Name
           LIMIT  125])
        {
         System.debug('#################### USAT_GD_ShareRefPageExtension MilePost getTeamMembers-0200'); 
         System.debug('#################### UList.Id: '   + UList.Id);  
         System.debug('#################### UList.Name: ' + UList.Name);  
         
         System.debug('#################### USAT_GD_ShareRefPageExtension MilePost getTeamMembers-0300'); 
         TeamMembers.add(new SelectOption(UList.Id, Ulist.Name));  
        }      
      
       System.debug('#################### USAT_GD_ShareRefPageExtension MilePost getTeamMembers-0400');       
       return TeamMembers;
       //return null;
    } 
    

 

 

 

Any clues are greatly appreciated. 

 

Thanks,

 

Chuck

Hi Friends,

 

          I want to add 6digits random to the inserted record which will be used as a unique id for the records. For Example,

In Standard User Object, when an user is created, i need add a value which is alphanumeric combination as follows:

 

Format:-

 

 ABC[2digit Country Code][xxxxxx].

 

 So, pls help me to solve this one.

 

Regards,

Phanikumar

How do you take a date value and determine if it falls within two other date values?

Hi,

 

Sort of a Salesforce newbie...

 

I created a new field and gave it a simple formula:

 

IF( ISBLANK(Source_Device__c), "Remote client", Source_Device__r.Name)

Basically it checks whether the Source Device field is empty for a particular record.

If it is, it outputs static text.

But if has a value, it outputs the 'Name' of that Source Device.

 

My question is: is there any way to make the 'Name' clickable (to link it to that object)? The 'Name' field is the primary key.

 

If you need any more clarification on this, please let me know. Thanks in advance.

  • November 10, 2011
  • Like
  • 0

Hello,

 

I'm tired of racking my brain on what seems to be a simple trigger and hoping someone can help. I'm trying to asssign an effort level on our Leads based on the queue it's assigned to. I need to take the queue name and convert it to a string, where it'll match the same string value on an unrelated object. The first concern is I'm not even sure I'm doing this right. Am I even querying for the right queue objects? My trigger is as follows:

 

trigger updateLeadEffort on Lead (before insert) {

  Set<Id> ownerIds = new Set<Id>();
  for (Lead l : Trigger.new)
      ownerIds.add(l.OwnerId);

  Map<Id, QueueSobject> q = new Map<Id, QueueSobject>([SELECT Id, Queue.Name from QueueSobject WHERE Id IN :ownerIds]);
  
  for (Lead l : Trigger.new) {

         if q.get(l.OwnerId).Name == customObjectField__c {
           l.effort__c = 'high';
    }
    else {
             l.effort__c = 'none';
    }
  }
}

 

Any help on enlightening me would be awesome. Thank you.

Hi,

 

I have a VisualForce form field which is used to pass an argument to an Apex method. 

 

I want lookup functionality (to the Campaign object) on this particular field. Users select a campaign, then it gets passed to the Apex method.

 

Is that somehow possible? 

Hello all, I was wondering whether anyone had any official documentation regarding the exact format of the case thread and the pre-spring 12 format. I've been looking online and some of the answers that have been given to people are slightly different in terms of behavior.

The spring 12 notes discuss (in criminally poor detail) the new format but do so with reference to the prior format - for which i was never able to find an official definition. Can anyone help with this?

thank you.

 

Hello all. I'm creating a controller to send an email but the heap size is 6mb and the act of creating attachments has the effect of creating duplicates (however briefly) of the list of attachments, which would suggest that for a synchronous execution, you can at most have 3mb (total) of attachments. This seems impossibly restrictive. Does anyone have any ideas (other than asynchronous apex) to address this? The requirement is to produce a custom email send functionality in an image heavy org. Consequently, they want to be able to send the maximum size of attachments. The question becomes: does this deep copy behavior represent an absolute limit or is there a potential workaround?

I would appreciate any help anyone is able to give.

thank you.

 

code/debug results to illustrate the problem:

 

Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();

Messaging.EmailFileAttachment[] someAttach= newlist<Messaging.EmailFileAttachment>();

attachment a = [Select a.Name, a.ContentType,a.Body FromAttachment a limit 1];

Messaging.EmailFileAttachment attach=new Messaging.EmailFileAttachment();

attach.setFileName(a.Name);

attach.setInline(false);

attach.Body=a.body;

attach.setContentType(a.ContentType);

someAttach.add(attach);

a = null;

System.debug('Limit pre: '+Limits.getHeapSize()+' out of '+Limits.getLimitHeapSize()+'.\n ');

if(!someattach.isEmpty()) mail.setFileAttachments(someAttach);

System.debug('xxx Limit post: '+Limits.getHeapSize()+' out of '+Limits.getLimitHeapSize()+'.\n ');

 

the above code produces:

 

09:51:51.686 (3686665000)|USER_DEBUG|[79]|DEBUG|Limit pre: 16761 out of 6000000.

09:51:51.687 (3687050000)|USER_DEBUG|[81]|DEBUG|xxx Limit post: 32386 out of 6000000.

 

which would seem to be a deep copy of the entire list and consequently presents problems for the heap limit.

i'm writing an email functionality that is likely to have attachments of significant size. Due to this, the heap becomes an increasing concern. While running some future code in the production org (in a future method called from a visualforce page), i recieved the following feedback from my code:

 

"Limit post: 14529108 out of 12000000."

 

Can anyone explain or refer me to an explanation of the heap that accounts for this seemingly odd behaviour.

Thank you.

i have some code that is running in a class that observes sharing but have observed that the code is sucessfully returning entries from emailtemplates, brandtemplates, users, profiles, folders while testing as a non-sysadmin user. My issue is, i don't know quite what to expect with these object - I don't know where they fit into the scheme of things. Can anyone direct me to a explanation of what objects or individual records a user can access when talking about objects on which the object permissions and the sharing model don't describe what is available (as seems to be the case) ?

thank you.

I need to be able to execute some Javascript based on the selection of an option from a select list, however have found that the onselect as offered with vforce doesn't work. nb. i can't use onchange because the selection is supposed to navigate to antoher page. I would appreciate any help anyone is able to give. thank you.

 

<apex:selectListvalue="{!fUpdateCurrent.Object__c}"multiselect="false" onselect="alert('select'); size="1"id="theopl">

<apex:selectOptionsvalue="{!objectPicks}"/>

</apex:selectList>

I am writing a VForce page controller to send an outbound message in response to an existing. The trouble is that emailmessages are not updateable via any normal mechanism, but i need for the original email's status to change to reflect that it has been responded to. Does anyone have an ideas regarding whether this is doable? I would be glad for any suggestions able to be provided or a definitive answer if what i hope to accomplish is possible.

thank you.

i'm trying to upload some files and store these on the controller and eventually send these. The error i get back is "Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 772.562KB". I need to be able to be able to store some blobs (upto 5mb of files extracted from attachments, files on c: and documents) on the controller, but the view state size seems to preclude this. The following is the simplest possible code to illustrate the problem at hand (a file is select, the savex operation causes bound variables to load, the page refreshes and exceeds limits) and a solution to this would enable me to address my actual code (too long to post). I would appreciate any help that could be given.

thank you.

 

 

 

public withsharingclass docController {

  

public document document {get; set;}

 

public docController() {

        document =new document();

    }

  

publicvoid savex()    {    }

}

 

<apex:page controller="docController">     <apex:messages />    

<apex:form id="theForm">       <apex:pageBlock >         

<apex:pageBlockSection >             <apex:inputFile value="{!document.body}" filename="{!document.name}"/>                         <apex:commandButton value="Save" action="{!savex}"/>         

</apex:pageBlockSection>        </apex:pageBlock>   

</apex:form>

</apex:page>



i'm trying to upload some files and store these on the controller and eventually send these. The error i get back is "Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 772.562KB". I need to be able to be able to store some blobs (upto 5mb of files extracted from attachments, files on c: and documents) on the controller, but the view state size seems to preclude this. The following is the simplest possible code to illustrate the problem at hand (a file is select, the savex operation causes bound variables to load, the page refreshes and exceeds limits) and a solution to this would enable me to address my actual code (too long to post). I would appreciate any help that could be given. 

thank you.

 

 

 

public withsharingclass docController {

   

public document document {get; set;}

 

public docController() {

        document =new document();

    } 

   

publicvoid savex()    {    }

}

 

<apex:page controller="docController">     <apex:messages />    

<apex:form id="theForm">       <apex:pageBlock >          

 <apex:pageBlockSection >             <apex:inputFile value="{!document.body}" filename="{!document.name}"/>                         <apex:commandButton value="Save" action="{!savex}"/>          

 </apex:pageBlockSection>        </apex:pageBlock>    

 </apex:form>

</apex:page>



ran the following and it keeps giving me back results in which the event's whoid field is null. Can anyone tell me what i am doing wrong? I've tried a couple different ways to reorder the query but it just keeps giving me back results with null. Can anyone tell me under what circumstance i can't trust testing such against null (it seems important) ? thank you.

 

contact[] cs= [Select c.id fromContact c

where c.isDeleted=false and c.hasoptedoutofemail=true];

lead[] lds= [Select l.id fromLead l

where l.isDeleted=false and l.HasOptedOutOfEmail=true];

 

datetime now=system.now();

datetime threeDaysAhead= now.addDays(3); datetime fourDaysAhead= now.addDays(4);

Event[] evs= [Select e.id, e.confirmEmail__c FromEvent e

where e.startdatetime>=:threeDaysAhead and e.startdatetime<:fourDaysAhead

and e.isDeleted=false and e.whoid not in :lds and e.whoid not in :cs

and e.whoid!=null

Order by e.startdatetime ASC Limit 400];

I inserted five events (subject = '1','2', etc). I searched on a) a set created using the ids of these b) a list of events.

In either case, i searched for events where id was in the set/list, recieved a correct number of records back, but they were all duplicates of the first event inserted. The following is the log for a debug statement of the set of ids, the query using these ids, and the results using a debug statement. any thoughts?

 

13:08:56.044 (2044220000)|USER_DEBUG|[78]|DEBUG|{00U90000003I98MEAS, 00U90000003I98NEAS, 00U90000003I98OEAS, 00U90000003I9C0EAK, 00U90000003I9C1EAK}

13:08:56.044 (2044288000)|SOQL_EXECUTE_BEGIN|[79]|Aggregations:0|select e.id, e.subject, e.whatid, e.whoid,

e.startdatetime from event e where e.id in:events

13:08:56.046 (2046644000)|SOQL_EXECUTE_END|[79]|Rows:5

13:08:56.046 (2046773000)|USER_DEBUG|[81]|DEBUG|subject: 1, id:00U90000003I98MEAS, whatid:0019000000A7orkAAB, whoid:true, 0039000000A7FiFAAV, starting: 2012-01-30 04:08:56

13:08:56.046 (2046840000)|USER_DEBUG|[81]|DEBUG|subject: 1, id:00U90000003I98MEAS, whatid:0019000000A7orkAAB, whoid:true, 0039000000A7FiFAAV, starting: 2012-01-30 04:08:56

(the remaining rows are the same)

Ran the following via an anonymous block. Said:Unrecognized base64 character: � (actually a diamond shaped thing)

The returned value that is anticipated as being a png file is not in a format that can be converted into a b64 file accurately. Does anyone know any methods that might be able to produce a correct b64 string/blob?

If anyone knew how to fix this or had sample code for getting images from google chart api, i would appreciate it.

thank you

 

HttpRequest req = new HttpRequest();

req.setEndpoint('https://chart.googleapis.com/chart?chs=250x100&chd=t:60,40&cht=p3&chl=Hello|World');

req.setMethod('GET');

Http http = new Http();

HTTPResponse res = http.send(req);

blob body;

 //body = blob.valueof(res.getBody());//produces corrupted body

 body = EncodingUtil.base64Decode(res.getBody()); //crashes

 

 

hello all,
I am trying to add an error on event when the event being entered coincides with existing. I want to be able to rollback the entire operation but create a separate object that is not included in the rollback. I would be grateful for any help that could be offered. If you have some expertise and believe it to be impossible, i would grateful if you would tell me - I have been trying to get a definitive answer for the last two weeks (good times.).



specifics:
1) I do not have access to the calling apex and as such cannot enclose it in a try/catch block. The event creation is occuring via the standard calendar interface. As such, I don't have access to override the calling methods and the people for whom i am writing this code are not organised enough to deploy greasemonkey to override the button. I am thus forced to find a means within a trigger to a) rollback and b) create a separate object that is not subject to the rollback. THESE HAVE TO OCCUR WITHIN A SINGLE TRANSACTION.
2) the desired behavior is on a new event to determine if it has a conflict and if so, rollback and create a object to log conflicts. A subsequent attempt to add a meeting with the same details will find the object storing the conflict and save anyway. A SECOND, MATCHING INSERT OPERATION OVERRIDES A CONFLICT.

 

i appreciate any help. thank you.
stc.

i was trying to add an error on event if meetings coincide and wanted to create an log object indicating that a conflict occured. I would appreciate if anyone knew if this were possible - that is, both rollback of the object on which the trigger is defined and some method of adding a separate object.

thank you.

I was wondering whether anyone knew how to access the data

for email to case. I am after the mapping of service names to routing

names and email addresses. the email services objects seem to have

the service name but not the rest. I would appreciate any help that

could be offered.

thank you.

1) when performing navigation within a component (stored in a page, embedded into the contact view), some of my links are misbehaving. The related list the page is replacing however behaves perfectly. upon inspection, it apparently uses different navigation mechanism via a normal page and via the console.

 

My issue is that due to the link occuring within the component (inside an html body, apparently), it doesn't receive the javascript necessary to determine whether the current view is the console. the javascript method i'm trying to use to confirm whether i'm in the console is:

 window.confirm(typeof(srcUp));

I would appreciate any suggestions if you have them.

 

2) does anyone know of any good resources about navigating within the console?

i wrote an action method that is using a page reference of a url to navigate from inside a custom component (inside a page embedded into the case standard layout). A call to a delete action method occurs and calls the page to reload.

When the page reloads (the desired behavior), the embedded page contains its own frame and subsequent action methods load in the embedded page section rather than the complete window. the url seems to have appended to it "inline=1" the action method that perfroms the navigation is

 as follows, where theId is the id of the case.

 

 

public PageReference deleteX()

{

String name = ApexPages.CurrentPage().getParameters().get('emailid');

EmailMessage e = [select e.id from emailMessage e where e.id =:name]; //Id e = Id.valueOf(name);

database.delete(e);

PageReference acctPage =new PageReference('/'+theId);

acctPage.setRedirect(true);

return acctPage; //return null;

}

Hi All

I am a newbie writing apex.I understand why I am getting this but I can not find a work around. I am writing a trigger that creates a custom object every time a new opportunity is created.  The possible workaround I may have,  is to pull all the data of Rep_assignments__c in a list and then use logic to get the values I need. I have about 27,000 record in there and do not find it an effective way to program. Any suggestions are appreciated,

Thanks

 

 

Here is my code:

I am calling this from a trigger.

 

public static void setpipeline (Opportunity [] opps)
 {
Date maxvalue = NULL ;
//build list of records
list<Rep_assignments__c> Records = new list<Rep_assignments__c>() ;
    list <date> dates = new List<date>();

List <print_pipeline__c> pipelinetoinsert = new List<print_pipeline__c>();

//need to put list of opportunities
list<Opportunity> Oppty = new List<Opportunity> ();

//build list of records of rep assignments
for (Opportunity z:opps)
    {
    
    
  if (z.RecordTypeId ==record_type &&  z.integration__c <> 1)
  records = [select r.id, r.Rep1_id__c,  r.Rep1_pct__c, r.Rep2_id__c, r.Rep2_pct__c, r.Rep3_id__c, r.Rep3_pct__c,  r.Rep4_id__c, r.Rep4_pct__c, r.effective_date__c
    from Rep_assignments__c r where r.brand__c = :z.brand__c and r.pub_id__c =:z.pub_id__c and r.effective_date__c <=:z.CloseDate ];
 }


//if more than one record found, then we need to get the max date and the array ref number to get the correct rep assignment
if (records.size() !=0)
{
    integer ref_num = 0;

    date maxdate;
    if (records.size() > 1)
        {
    
        for (integer i = 0; i < records.size(); i++)
        {
            
          dates.add((records.get(i).effective_date__c));  
         }
         //get max date
         maxdate = dates[0];
         
         for (integer i = 0; i < dates.size(); i ++){
           if (dates[i] > maxdate)
           maxdate = dates[i];    
         }
        }
        //get ref number
        
        for (integer i=0; i <Records.size(); i++){
            if (records[i].Effective_Date__c == maxdate)
            ref_num= i;
        }  

//create print pipe
    
    for (Opportunity o:opps){
    
    if (records.get(ref_num).rep1_id__c != null)
    {
            print_pipeline__c pipeline = new print_pipeline__c (Opportunity__c=o.id ,
             Rep_assignment__c=records.get(ref_num).id,     Sales_Rep__c=records.get(ref_num).Rep1_id__c,
            Rep_split__c=records.get(ref_num).Rep1_pct__c );
                pipelinetoinsert.add(pipeline);    
       
    }
    if (records.get(ref_num).rep2_id__c != null){
               print_pipeline__c pipeline = new print_pipeline__c (Opportunity__c=o.id , Rep_assignment__c=records.get(ref_num).id,     Sales_Rep__c=records.get(ref_num).Rep2_id__c,
                Rep_split__c=records.get(ref_num).Rep2_pct__c );
                pipelinetoinsert.add(pipeline);    
    }
    if (records.get(ref_num).rep3_id__c != null)
    {
               print_pipeline__c pipeline = new print_pipeline__c (Opportunity__c=o.id , Rep_assignment__c=records.get(ref_num).id,     Sales_Rep__c=records.get(ref_num).Rep3_id__c,
                Rep_split__c=records.get(ref_num).Rep3_pct__c );
                pipelinetoinsert.add(pipeline);    
    }
    if (records.get(ref_num).rep4_id__c != null)
    {
               print_pipeline__c pipeline = new print_pipeline__c (Opportunity__c=o.id , Rep_assignment__c=records.get(ref_num).id,     Sales_Rep__c=records.get(ref_num).Rep4_id__c,
                Rep_split__c=records.get(ref_num).Rep4_pct__c );
                pipelinetoinsert.add(pipeline);    
    }
    }


if (!pipelinetoinsert.isEmpty())
database.insert(pipelinetoinsert);
}

}

REQUIREMENT :- Need to be able to delete Opportunities via data loader. 
i.e when i'm trying to delete some opportunites through DATA LOADER i'm getting the below ERROR :-


Getting the following message: 
tgrOpportunityBefore: execution of BeforeDelete 
caused by: System.NullPointerException: Attempt to de-reference a null object 
Trigger.tgrOpportunityBefore: line 379, column 1 

 

 

 

TRIGGER :-

 

 // --- This is used since most of the triggers are for Insert and Update on Opportunity.
    if(trigger.isInsert || trigger.isUpdate) {  
      //#101OICD - Variable Declaration -- Start    
      StaticVariables.setAccountDontRun(true); // stop account trigger from running
      List<Id> accIds = new List<Id>();
      Set<id> accidset = new set<id>();
      //#101OICD - Variable Declaration -- End
      
   
 
      //#101OICD -- Loop Through Opp records  and assign values -- Start
      for(Opportunity o:Trigger.new) {
        
        system.debug('Originator EIN ' + o.Originator_EIN__c);
        allCampaignIds.add(o.CampaignId);//CR2180        
        //if(o.Opportunity_Owner_EIN__c == '802558891') o.ABR_Count__c =1;  
        
     
        
        if(o.CloseDate ==null)o.CloseDate = (Date.today()+ 365);
        
        if(o.AccountId != null && o.Auto_Assign_Owner__c)accIds.add(o.accountId);
        
        if(o.OwnerId != null)o.owner__c = o.OwnerId;
        
        //add flag for org to org
        if (
        (o.Routing_Product__c == 'Engage IT' || o.Product_Family__c == 'ENGAGE IT') 
        && o.CreatedDate >= (date.newinstance(2011, 11, 19))  
        //    || ((trigger.newmap.get(o.id).Routing_Product__c != trigger.oldmap.get(o.id).Routing_Product__c)
        //    || (trigger.newmap.get(o.id).Product_Family__c != trigger.oldmap.get(o.id).Product_Family__c ))
        ){
            o.s2s_Link__c = 'BTB to Engage IT';  
        }
        

    //#101OICD -- Part of 101OICD Trigger to Modify Opportunit Owner By Account -- End
     
     //#101OICD -- Part of 101OICD Trigger to Modify Account Information -- Start
        //Added by GS to update account last call date.
        //Update the account last call date field for these accounts      
        list<account> updateCallDate = new list<account>();          
        updateAccountLastContacted updateAccountCallDate = new updateAccountLastContacted();                     
        //updateCallDate = updateAccountCallDate.updateAccount(accidset);
        String objName='Opportunities';
        updateCallDate = updateAccountCallDate.updateAccount(accidset, objName);           
        update updateCallDate;               
    //#101OICD -- Part of 101OICD Trigger to Modify Account Information -- End
    }
     
    //Set RAG Status to None if Leasing History has 0 records -- Start
   LINE 379 :- for(Opportunity o : trigger.new){
    Integer i = [SELECT count() FROM Leasing_History__c WHERE Opportunity__c =: o.Id LIMIT 1];
    if(i < 1){
      o.Finance_Available__c = 'None';
     }
    }    
    //Set RAG Status to None if Leasing History has 0 records -- End   
}

Hello, senior,

 

and I met above problem 'No standard price defined for this product',
I try to use

      'Pricebook2 pricebook = [Select p.I d, p.N ame from Pricebook2 p where isActive = true and isStandard = true Limit 1];       'code for object, but called the

      ' List has no rows for assignment to SObject 'mistakes

       don't know what to do, hope to get solutions thank

Hello all. I'm creating a controller to send an email but the heap size is 6mb and the act of creating attachments has the effect of creating duplicates (however briefly) of the list of attachments, which would suggest that for a synchronous execution, you can at most have 3mb (total) of attachments. This seems impossibly restrictive. Does anyone have any ideas (other than asynchronous apex) to address this? The requirement is to produce a custom email send functionality in an image heavy org. Consequently, they want to be able to send the maximum size of attachments. The question becomes: does this deep copy behavior represent an absolute limit or is there a potential workaround?

I would appreciate any help anyone is able to give.

thank you.

 

code/debug results to illustrate the problem:

 

Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage();

Messaging.EmailFileAttachment[] someAttach= newlist<Messaging.EmailFileAttachment>();

attachment a = [Select a.Name, a.ContentType,a.Body FromAttachment a limit 1];

Messaging.EmailFileAttachment attach=new Messaging.EmailFileAttachment();

attach.setFileName(a.Name);

attach.setInline(false);

attach.Body=a.body;

attach.setContentType(a.ContentType);

someAttach.add(attach);

a = null;

System.debug('Limit pre: '+Limits.getHeapSize()+' out of '+Limits.getLimitHeapSize()+'.\n ');

if(!someattach.isEmpty()) mail.setFileAttachments(someAttach);

System.debug('xxx Limit post: '+Limits.getHeapSize()+' out of '+Limits.getLimitHeapSize()+'.\n ');

 

the above code produces:

 

09:51:51.686 (3686665000)|USER_DEBUG|[79]|DEBUG|Limit pre: 16761 out of 6000000.

09:51:51.687 (3687050000)|USER_DEBUG|[81]|DEBUG|xxx Limit post: 32386 out of 6000000.

 

which would seem to be a deep copy of the entire list and consequently presents problems for the heap limit.

I currently have this written which isn't working out because sometimes people reopen cases

trigger UpdateResoTCategor on Case (before update) {

  Double timeStat;
  BusinessHours bh = [select id from businesshours where isDefault = true];
  
  for (Case c : Trigger.new){
    Case oldCase = Trigger.oldMap.get(c.ID);
      
      if (oldCase.Status != 'Closed' && (c.Status == 'Closed' || c.Status == 'Escalated')){
        timeStat = BusinessHours.diff(bh.id, c.CreatedDate, System.now())/3600000.0;
           
        c.TimeBetweenCase__c = timeStat;    
      }    
  }
}

 I want to calculate the time difference between open and closed in BusinessHouses based on CreatedDateTime and ClosedDateTime but the problem is that isClosed and the ClosedDate don't actually get genereated til afterwards. I tried to do the same thing on after update and used the ClosedDate field but I keep getting errors on it: "execution of AfterUpdate caused by: System.FinalException: Record is read-only"

 

Does anyone have any ideas on how to do this?

 

  • August 10, 2012
  • Like
  • 0

I have a simple vf page, I am trying to set the checkbox value selected to true. But it doesnt work when the page is displayed the checkboxes are  unchecked.

 

<apex:page standardController="Opportunity" extensions="Test">
 
  <apex:form id="theform">
      <apex:actionFunction action="{!click}" name="displayFunction"  rerender="" id="afunc">
                <apex:param name="stageV" value="" id="aparam"/>
      </apex:actionFunction>
      
      <apex:pageBlock id="pageblock">
            <apex:repeat value="{!stageValue}" var="s">
                <apex:outputLabel value="{!s.Name}"/>
                <apex:inputCheckbox selected="true" />
            </apex:repeat>
        </apex:pageBlock>  
  </apex:form>
</apex:page>

I have a scheduled job that runs nightly which basically updates any team member that is active and becomes inactive due the the start and end date and visa versa.  When update these records there are a lot of triggers that get set off.  If the list of active --> Inactive or the inactive -->active is too big I will run into soql limits

 

In my code put a limit on the query to only retrieve x amount for inactive or active lists.  but really I need it to run all of them

 

any way of accomplishing this.

 

Hi ,

In my application, I want to write scheduler.The code from schduler is executing for each user from organization.

For each user, I have to execute arrount 20 DML +SOQL statements.
I have more than 100 user so getting Limit exception :Too many SOQL :101


Can anyone help?

 

Thanks in advance.

 

Regards,
Dipak

i have some code that is running in a class that observes sharing but have observed that the code is sucessfully returning entries from emailtemplates, brandtemplates, users, profiles, folders while testing as a non-sysadmin user. My issue is, i don't know quite what to expect with these object - I don't know where they fit into the scheme of things. Can anyone direct me to a explanation of what objects or individual records a user can access when talking about objects on which the object permissions and the sharing model don't describe what is available (as seems to be the case) ?

thank you.

 

Hi friends,

 

Below given code I have taken directly from a tutoria.It works in the tutorial.However,when I run in salesforce,It just doesn't do anything .I do not what is wrong.Can somebody point out.

<Apex:page >
<html>
<head>
<script type="text/javascript">
function OnUnload()
{
alert ("The current document will be unloaded!");
}
</script>
</head>
<body onunload="OnUnload()">

<p>Close this window or press F5 to reload the page.</p>

</body>
</html>
</apex:page>

 

 

Thanks,

Trick

Naive question, how to update a custom master object  with distinct child counts on nightly basis?

Any input is highly appreciated.

 

Thanks

Hi,

 

I am writing trigger to delete custom objects upon deletion of a Campaign. 

 

Is there a limit of how many records can be deleted in a trigger?

 

I need to delete upto 300,000 records so wondering if this is possible to delete in a trigger. If not, is it possible to create Apex Job and execute in a trigger?

 

Thanks,

how to create and put dropdownlist in visualforce page?i mean to say take an example country.no.of countries is there.how to take it as a dropdown or picklist in visaul force page.is there any need to create a custom controller.if it is need.pls clarify this how to create apex class for this purpose in visual force page.pls clarify i will wait.

thanks in advance.

Hi,

 

We are planning to build a functionality where we need to have a report to check the number of times a record is viewed on the Account object. 

 

I need to build a apex code which will capture the number of times a record is opened. Can anybody help or suggest me how can I achieve this. 

 

Would appreciate any help regarding this as it is critical.

 

 

Hello all,

 

I have a trigger (case before update) in which I want to do different things depending upon whether the trigger occurs in a batch or single context. (This is to get around a problem I have with a @future method being called from within batch mode)

 

Is there a way to tell if the context is in batch mode? I haven't found anything about this in the docs or forums.

 

Thanks for any help,

Graeme

 

  • June 21, 2012
  • Like
  • 0