• sf_evolution
  • NEWBIE
  • 100 Points
  • Member since 2012

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 30
    Replies


This is a trigger which is meant to create child records based upon a multi-value field in a parent record at the time the parent is saved. It doesn't seem to be creating the records upon being saved :

trigger AutoCreateSubs on Contract_Overview__c (after insert) {
 List<Subs_Serviced_On_Contract__c> subs = new List<Subs_Serviced_On_Contract__c>();

    //For each position processed by the trigger, add a new  

    //Subs_Serviced_On_Contract record for the specified Subsidiaries_On_Contract__c.  

    //Note that Trigger.New is a list of all the new positions  

    //that are being created.  

    for (Contract_Overview__c newContract : Trigger.New) {
        if (newContract.Subsidiaries_On_Contract__c != null) {
            // split out the multi-select picklist using the semicolon - or comma -delimiter
            for(String subsoncontract: newContract.Subsidiaries_On_Contract__c.split(',')){
                subs.add(new Subs_Serviced_On_Contract__c(
                        Name = newContract.Id,
                        Contract_Overview__c = newContract.Id,
                        Subsidiary_Name__c = (Id)subsoncontract,
                        Logo_Usage_Allowed__c = 'Yes'));
            }
        } 
    }
    insert subs;

}

 

The trigger is at 100% code coverage and is Active. There is a value in the Subsidiaries_On_Contract_c field, so that wouldn't be preventing it from firing off.

Does anybody see anything wrong with this code which would prevent it from creating the records ? I'm not sure if it is error-ing out or not even firing off. Can somebody give me some direction on this ?

Thank you very much for your help.

 

 

Hi all,

 

This is really just a request for information, but  it just seems like I'm making things way too hard on myself.

I typically use inputText boxes for date input, so that may be coloring what  sems to go on in my code.
Basically, I can't seem to get data from the VF page to the controller without using an apex:actionFunction.

For example, this APEX class has to have data and a method for processing the <apex:actionFunction> tag:

public class OpportunityHistoryController {
  ...
  public String From_Date {get;set;}  // 
  ...
  public void dateChange() {
      System.debug('DATECHANGE WAS MADE:');
      ...
    }

   ...

 And next, the VF page markup calls the controller function:

<apex:page controller="OpportunityHistoryController" id="opportunityHistPage">
<apex:form id="OpportunityForm">
<script>
function DynamicDatePicker(d_id) {
 DatePicker.pickDate(false,d_id.id,false);
 dateChange(d_id);
 }
function checkDateFormat() {}
</script>
   <apex:pageBlock title="Opportunity History Statement" id="pb1">
    
    <apex:actionFunction action="{!dateChange}" reRender="condisplay" name="dateChange">
     <apex:param value="" assignTo="{!dummy}" name="assignvalue"/>
    </apex:actionFunction>
     
    From: <apex:inputText value="{!From_Date}" id="f" onfocus="DynamicDatePicker(this);" onchange="checkDateFormat(this.id);" onblur="setFocusOnLoad()" size="20" disabled="false"/>

     ...

 Now, why the <apex:actionFunction> is needed, I have no clue - all I know is that most of my code seems to not update values between the page and the controller unless there is some linkage between the two.  In fact, the "dateChange()" function in the controller doesn't really have to do anything - it just has to be present.

My suspicion is there is something going on with the MVC architecture with SFDC that is necessitating this "connection" between the two to notify the controller that the VF page is "dirty" - If anyone has a documentation reference on other ways to do this, I'd very much appreciate it.

Similarly, with SelectLists, I seem to have to make up similar coding  -

For instance, Taking the OpportunityHistoryController example I'm messing with above, and add the following subroutines:

public class OpportunityHistoryController {
  ...
        public  Map<id,UserRole> maplstroles{get;set;}
        public UserRole theRole {get;set;}  // Role ID
        ...
        public OpportunityHistoryController() {
	    ...
	    maplstroles = new Map<id,UserRole>();            
    	    }

	// build Role SelectOptions
        public List<SelectOption> getRolesLst(){
           System.debug('Entering getRolesLst');
           options.clear();
           options.add(new selectOption('--None--','-- Select Role --'));
           for(UserRole rx:[SELECT ID, Name From UserRole  ORDER BY Name ASC]){
             options.add(new selectOption(rx.id,rx.name));
             maplstroles.put(rx.id,rx);
             }
           return options;
           }


	 // process the "apex:actionFunction " call...
	 public void RoleID() {
	    System.debug('getting roleID for: ' + rid);
	    theRole =  maplstroles.get(rid);
	    System.debug('theRole.Id: ' + theRole.Id);
	    System.debug('theRole.Name: ' + theRole.Name);
	    }

 ...And somewhere in the VF markup, I want to update the apex page:

<apex:page controller="OpportunityHistoryController" id="opportunityHistPage">
<apex:form id="OpportunityForm">
<script>
function callactionfun(picklistval){
   change(picklistval);
   }
</script>
  ...
   <apex:pageBlock title="Opportunity History Statement" id="pb1">
    ...
    <apex:actionFunction action="{!RoleID}" reRender="condisplay" name="change">
     <apex:param value="" assignTo="{!rid}" name="assignvalue"/>
    </apex:actionFunction>

     ...
     
    <apex:selectList value="{!rid}" multiselect="false" size="1"  
    			onchange="callactionfun(this.options[this.selectedIndex]);" >
        <apex:selectOptions value="{!RolesLst}"/>
    </apex:selectList>

...

 ...It's really just a personal opinion, but it looks like SFDC is following more of the "MVVC" model - where we basically have to notify the controller of changes that occur on the view.   

Sorry, but I'm still doing research on this.  
But if anyone has ideas about how to make coding for dynamic input easier, I'd appreciate it.

 

 

 

 

 

 

Hello friends,

 

I amhaving the list of  custom object t which i want to give numbers bt all the time it is giving me list of work order of same name.


public static integer c=0;
public ID QID {get; set;}
public List<ID> ProdList=new List<ID>();
public Work_Orders__c wo = new Work_Orders__c();
public list< Work_Orders__c> wos = new list<Work_Orders__c>();
public list<Work_Orders__c> woinsert = new list<Work_Orders__c>();
public Quote q = new Quote();
Public list<QuoteLineItem> QlIm=new list<QuoteLineItem>();
public list <Work_Schedule__c> wslist=new list<Work_Schedule__c>();
public list <Work_Schedule__c> wslist1=new list<Work_Schedule__c>();
public set<date> datelist=new set<date>();
public List<date> listdate=new List<date>();
integer i;
public void ConvertWorkOrder()
{
QID = ApexPages.currentPage().getParameters().get('ID');
QlIm=[ SELECT ListPrice, PricebookEntryId, Quantity, QuoteId, Id, UnitPrice FROM QuoteLineItem where QuoteId=:QID];
system.debug('@@@@@@@@@@@@@@@@@@'+QlIm);
wslist=[select date__c,product__c,quote__c from Work_Schedule__c where quote__c =:QID and product__c!=null];
system.debug('*****************'+QlIm);
for(Work_Schedule__c w:wslist)
{

datelist.add(w.date__c);
}

for(date d:datelist)
{
listdate.add(d);
}
system.debug('lllllllllllllllllllll'+datelist);
for(i=0;i<listdate.size();i++)
{

for(Work_Schedule__c ws:[select date__c,product__c,quote__c from Work_Schedule__c where quote__C=:QID and date__c=:listdate.get(i)])
{
wslist1.add(ws);
}

}
system.debug('*******List of WOrk Order*********'+wslist1);
integer n=listdate.size();

for(i=0;i<n;i++)
{
system.debug('bbbbbbbbbbbbbbbbbb'+i);

for(quote q : [Select ID, Name, Description, Summary__c, Notes__c, OpportunityID, contactID, Opportunity.AccountId,Opportunity.Location__c from Quote where Id =: QID])
{
string name;
if(q != null)
{
wo.Name =q.name;
wo.Quote__c = q.ID;

}
woinsert.add(wo);

}


}

system.debug('WWWWWWWWWWWWWWWWW'+woinsert);
for(Work_Orders__c won:woinsert )
{
integer k;
k=c;
system.debug('ccccccccccc'+k);
won.name=string.valueOf(k);
wos.add(won);
c++;
system.debug('ooooooooooooooo'+wos);

}




}
}

I have deployed a small app - with Apex, Tests - via a Change Set.

Usually use packages.

 

Well, as usual, there are changes to the functionality.

 

I need to remove the Apex code from production. But can't.

 

Removing the 'Change Set' won't remove the code.

 

So the question is, how do I remove apex classes and triggers that deployed via a Change Set??

 

Uber Thx In Advance.

Hi,

 

I have employee_id__c field in custom object Opportunity_CRM__c. It has duplicate values as single employee can create multiple opportunities. I have to insert unique employee_id from Opportinity_CRM__c into employee_id__c field in another custom object test__c. Insert operation is successful using trigger below. But i cant eliminate duplicate values. So plz help me.

 

trigger employee_id on Opportunity_CRM__c (after insert) 
{
        List<Test__c> test = new List<Test__c>();
        Set<Opportunity_CRM__c> myset = new Set<Opportunity_CRM__c>();
        List<Opportunity_CRM__c> mylist = new List<Opportunity_CRM__c>();                                                        
        List<Opportunity_CRM__c> result = [select Employee_ID__c from Opportunity_CRM__c];
        for (Opportunity_CRM__c s : Trigger.new) 
        {
            if (myset.add(s)) 
            {
               Test__c mytest = new Test__c();
               mytest.Employee_ID__c = s.Employee_ID__c;
               test.add(mytest);
            }
        }
       try 
       {
            insert test; 
       } 
       catch (system.Dmlexception e) 
       {
            system.debug (e);
       }
    }

I am desperate for some help.  I have a trigger and help class for the Task object.  It was originally written by our implementer but it appears that he failed to bulkify the trigger and helper class.  I have been trying to hack my way through fixing this with no luck and my company won't give me the money to hire someone to fix it.  I would appreciate any help I could get. 

 

This trigger and helper class is preventing me from updating 100,000+ tasks. 

 

Trigger

 

trigger TaskTrigger on Task (after insert, after update)
{
if(trigger.isAfter) TaskActions.UpdateLastActivityDate(trigger.new);
}

 

Helper Class

 

public with sharing class TaskActions 
{
  static public void UpdateLastActivityDate(List<Task> triggerTasks)
  {
    Set<Id> whatIds = new Set<Id>();
    Set<Id> whoIds = new Set<Id>();
    Set<Id> ownerIds = new Set<Id>();
    for(Task triggerTask:triggerTasks)
    {
      if(!whatIds.contains(triggerTask.WhatId)) whatIds.add(triggerTask.WhatId);
      if(!whoIds.contains(triggerTask.WhoId)) whoIds.add(triggerTask.WhoId);
      if(!ownerIds.contains(triggerTask.OwnerId)) ownerIds.add(triggerTask.OwnerId);
    }
    if(whatIds.size()>0&&ownerIds.size()>0)
    {
      Map<Id,User> ownerMap = new Map<Id,User>([SELECT Id, Profile.Name FROM User WHERE Id IN :ownerIds]);

      Map<Id,Contact> contactMap = new Map<Id,Contact>([SELECT Id, AccountId FROM Contact WHERE Id IN :whoIds]);
      for(Contact contact:contactMap.values()) { if(!whatIds.contains(contact.AccountId)) whatIds.add(contact.AccountId); }

      Map<Id,Applications__c> applicationMap = new Map<Id,Applications__c>([SELECT Id, Dealer__c FROM Applications__c WHERE Id IN :whatIds]);
      for(Applications__c application:applicationMap.values()) { if(!whatIds.contains(application.Dealer__c)) whatIds.add(application.Dealer__c); }

      Map<Id,Contract> contractMap = new Map<Id,Contract>([SELECT Id, AccountId FROM Contract WHERE Id IN :whatIds]);
      for(Contract contract:contractMap.values()) { if(!whatIds.contains(contract.AccountId)) whatIds.add(contract.AccountId); }

      Map<Id,Account> accountMap = new Map<Id,Account>([SELECT Id, Last_Activity_Date_ACA__c, Last_Activity_Date_AF__c, Last_Activity_Date_AFN__c FROM Account WHERE Id IN :whatIds]);

      Map<Id,Account> accountUpdateMap = new Map<Id,Account>();
      for(Task triggerTask:triggerTasks) 
      {
        Account account = accountUpdateMap.get(triggerTask.WhatId);
        if(account==null) account = accountMap.get(triggerTask.WhatId);
        if(account==null)
        {
          Applications__c application = applicationMap.get(triggerTask.WhatId);
          if(application!=null) account = accountMap.get(application.Dealer__c);
        }
        if(account==null)
        {
          Contract contract = contractMap.get(triggerTask.WhatId);
          if(contract!=null) account = accountMap.get(contract.AccountId);
        }
        if(account==null)
        {
          Contact contact = contactMap.get(triggerTask.WhoId);
          if(contact!=null) account = accountMap.get(contact.AccountId);
        }
        User owner = ownerMap.get(triggerTask.OwnerId);

        if(account!=null&&owner!=null)
        {
          if(owner.Profile.Name.Contains('ACA')||Test.isRunningTest()) account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          if(owner.Profile.Name.Contains('AFN')||Test.isRunningTest()) account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          if((!owner.Profile.Name.Contains('AFN')&&owner.Profile.Name.Contains('AF'))||Test.isRunningTest()) account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          //for testing only
          //account.Last_Activity_Date_ACA__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AFN__c = triggerTask.LastModifiedDate.Date();
          //account.Last_Activity_Date_AF__c = triggerTask.LastModifiedDate.Date();

          accountUpdateMap.put(account.Id,account);
        }
      }
      if(accountUpdateMap!=null&&accountUpdateMap.values().size()>0) update accountUpdateMap.values();
    }
  }

  static private testMethod void testAccountActions()
  {
    Account account = [SELECT Id, OwnerId FROM Account ORDER BY LastModifiedDate DESC LIMIT 1];
    Applications__c application = [SELECT Id, OwnerId FROM Applications__c WHERE Dealer__c != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contract contract = [SELECT Id, OwnerId FROM Contract WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];
    Contact contact = [SELECT Id, OwnerId FROM Contact WHERE AccountId != null ORDER BY LastModifiedDate DESC LIMIT 1];

    List<Task> tasks = new List<Task>();
    tasks.add(new Task(WhatId=account.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=application.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhatId=contract.Id,OwnerId=UserInfo.getUserId()));
    tasks.add(new Task(WhoId=contact.Id,OwnerId=UserInfo.getUserId()));
    Test.StartTest();
    insert tasks;
    tasks = [SELECT Id, WhatId, WhoId, LastModifiedDate, OwnerId FROM Task WHERE Id IN:tasks];
    UpdateLastActivityDate(tasks);
    Test.StopTest();
  }
}

 

Hi all,

I'm trying an approach to a problem I'm having of scheduling a report to return a CSV file to a specified user via email.

I'm doing this by scheduling a VF page via a HTTP callout.

 

All indications in the debug logs seem to say all is working, but I never get the results emailed to me.

The email address and the report ID are stored in a Custom settings group down in the Exporter class...

 

My Scheduled class is as follows

global class ReportExporter implements System.Schedulable {
    global void execute(SchedulableContext sc) {
    getmailReportOutput gem = new getmailReportOutput();
    gem.runReport();
    }
}

 The class that is doing the HTTP callout to the VF page calling the class that generates and emails the report:

public class getmailReportOutput{
    public Static String strSession;
    public getmailReportOutput() {
        }
    
    public void runReport() {
strSession = UserInfo.getSessionId(); makeReportRequest(); } @future (callout=true) public static void makeReportRequest() { ReportName__c mc = ReportName__c.getValues('ReportName'); String strEmailAddr = mc.RptEmail__c; URL xHost = System.URL.getSalesforceBaseUrl(); String strHost =xHost.getHost(); String requestUrl = 'https://' + strHost + '/apex/TestSendReport'; HttpRequest req = new HttpRequest(); req.setEndpoint(requestUrl); req.setMethod('GET'); req.setHeader('Cookie','sid=' + strSession;); String output = new Http().send(req).getBody(); } }

 

The VF page that calls the class that generates the report and emails the CSV file is very simple - it just calls a controller and a method that builds the attachmnent and sends it::

 

<apex:page controller="Exporter" action="{!executeRpt}">
  <!-- Begin Default Content REMOVE THIS -->  
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

The page controller is as follows;

public class Exporter {
    public static Boolean isTest;
    public static String strEmailAddr;
    
    public void executeRpt() {
        System.debug('CALLING REPORT EXPORTER...');        
        ReportName__c mc = ReportName__c.getValues('ReportName');
        strEmailAddr =  mc.RptEmail__c;
        
        System.debug('ReportName:' +  mc.RptName__c);
        System.debug('EmailAddr:' + mc.RptEmail__c);
        integer a = 1;
        ApexPages.PageReference report = new ApexPages.PageReference( '/' + mc.RptName__c + '?csv=1');
         
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.csv');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] { strEmailAddr } );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );        
    }
 
}

 

When I schedule the ReportExporter class to run, the debug log on the developer console doesn't seem to show any obvious errors:

 

 27.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
 09:38:36.303 (303605000)|EXECUTION_STARTED
 09:38:36.303 (303665000)|CODE_UNIT_STARTED|[EXTERNAL]|066P00000008yb8|VF: /apex/TestSendReport
 09:38:36.305 (305060000)|CODE_UNIT_STARTED|[EXTERNAL]|01pP0000000DlLl|Exporter <init>
 09:38:36.305 (305077000)|SYSTEM_MODE_ENTER|true
 09:38:36.305 (305682000)|VARIABLE_SCOPE_BEGIN|[2]|Exporter.isTest|Boolean|false|true
 09:38:36.305 (305708000)|VARIABLE_SCOPE_BEGIN|[3]|Exporter.strEmailAddr|String|false|true
 09:38:36.306 (306327000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:15
 09:38:36.306 (306345000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:36.306 (306372000)|METHOD_ENTRY|[1]|01pP0000000DlLl|Exporter.Exporter()
 09:38:36.306 (306384000)|STATEMENT_EXECUTE|[1]
 09:38:36.306 (306394000)|STATEMENT_EXECUTE|[1]
 09:38:36.306 (306403000)|METHOD_EXIT|[1]|Exporter
 09:38:36.306 (306423000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
 09:38:36.306 (306441000)|VARIABLE_SCOPE_BEGIN|[1]|this|Exporter|true|false
 09:38:36.306 (306511000)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x16d8f5e4
 09:38:36.306 (306530000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:1
 09:38:36.306 (306567000)|VARIABLE_SCOPE_BEGIN|[2]|this|system.ApexBaseClass|true|false
 09:38:36.306 (306609000)|VARIABLE_ASSIGNMENT|[2]|this|{}|0x16d8f5e4
 09:38:36.306 (306631000)|STATEMENT_EXECUTE|[1]
 09:38:36.306 (306648000)|CODE_UNIT_FINISHED|Exporter <init>
 09:38:36.306 (306707000)|CODE_UNIT_STARTED|[EXTERNAL]|01pP0000000DlLl|Exporter invoke(executeRpt)
 09:38:36.306 (306753000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
 09:38:36.306 (306771000)|VARIABLE_SCOPE_BEGIN|[30]|this|Exporter|true|false
 09:38:36.306 (306812000)|VARIABLE_ASSIGNMENT|[30]|this|{}|0x16d8f5e4
 09:38:36.306 (306834000)|STATEMENT_EXECUTE|[30]
 09:38:36.306 (306841000)|STATEMENT_EXECUTE|[31]
 09:38:36.306 (306884000)|HEAP_ALLOCATE|[31]|Bytes:26
 09:38:36.307 (307021000)|SYSTEM_METHOD_ENTRY|[31]|System.debug(ANY)
 09:38:36.307 (307057000)|USER_DEBUG|[31]|DEBUG|CALLING REPORT EXPORTER...
 09:38:36.307 (307067000)|SYSTEM_METHOD_EXIT|[31]|System.debug(ANY)
 09:38:36.307 (307078000)|STATEMENT_EXECUTE|[32]
 09:38:36.307 (307089000)|HEAP_ALLOCATE|[32]|Bytes:10
 09:38:36.307 (307264000)|SYSTEM_METHOD_ENTRY|[32]|ReportName__c.getValues(String)
 09:38:36.308 (308279000)|HEAP_ALLOCATE|[32]|Bytes:48
 09:38:36.308 (308301000)|SYSTEM_METHOD_EXIT|[32]|ReportName__c.getValues(String)
 09:38:36.308 (308315000)|VARIABLE_SCOPE_BEGIN|[32]|mc|ReportName__c|true|false
 09:38:36.308 (308551000)|VARIABLE_ASSIGNMENT|[32]|mc|{"serId":1,"value":{"Name":"ReportName","SetupOwnerId":"00DP00000007CFaMAM","RptName__c":"00OP0000000Jp3N","LastModifiedById":"00500000006w214AAA","SystemModstamp":"2013-01-24T19:50:17.000Z","CreatedById":"00500000006w214AAA","RptEmail__c":"user@city (13 more) ...","CreatedDate":"2013-01-24T01:04:12.000Z","IsDeleted":false,"LastModifiedDate":"2013-01-24T19:50:17.000Z","Id":"a0LP0000005FKc4MAG"}}|0x77cda7ca
 09:38:36.308 (308570000)|STATEMENT_EXECUTE|[33]
 09:38:36.308 (308632000)|VARIABLE_ASSIGNMENT|[33]|Exporter.strEmailAddr|"user@city (13 more) ..."
 09:38:36.308 (308644000)|STATEMENT_EXECUTE|[35]
 09:38:36.308 (308655000)|HEAP_ALLOCATE|[35]|Bytes:11
 09:38:36.308 (308695000)|HEAP_ALLOCATE|[35]|Bytes:26
 09:38:36.308 (308712000)|SYSTEM_METHOD_ENTRY|[35]|System.debug(ANY)
 09:38:36.308 (308736000)|USER_DEBUG|[35]|DEBUG|ReportName:00OP0000000Jp3N
 09:38:36.308 (308745000)|SYSTEM_METHOD_EXIT|[35]|System.debug(ANY)
 09:38:36.308 (308755000)|STATEMENT_EXECUTE|[36]
 09:38:36.308 (308766000)|HEAP_ALLOCATE|[36]|Bytes:10
 09:38:36.308 (308783000)|HEAP_ALLOCATE|[36]|Bytes:43
 09:38:36.308 (308796000)|SYSTEM_METHOD_ENTRY|[36]|System.debug(ANY)
 09:38:36.308 (308817000)|USER_DEBUG|[36]|DEBUG|EmailAddr:user@citymedia.com
 09:38:36.308 (308825000)|SYSTEM_METHOD_EXIT|[36]|System.debug(ANY)
 09:38:36.308 (308835000)|STATEMENT_EXECUTE|[37]
 09:38:36.308 (308854000)|VARIABLE_SCOPE_BEGIN|[37]|a|Integer|false|false
 09:38:36.308 (308861000)|HEAP_ALLOCATE|[37]|Bytes:4
 09:38:36.308 (308885000)|VARIABLE_ASSIGNMENT|[37]|a|1
 09:38:36.308 (308895000)|STATEMENT_EXECUTE|[42]
 09:38:36.308 (308913000)|HEAP_ALLOCATE|[42]|Bytes:1
 09:38:36.308 (308930000)|HEAP_ALLOCATE|[42]|Bytes:16
 09:38:36.308 (308940000)|HEAP_ALLOCATE|[42]|Bytes:6
 09:38:36.308 (308950000)|HEAP_ALLOCATE|[42]|Bytes:22
 09:38:36.309 (309019000)|VARIABLE_SCOPE_BEGIN|[42]|report|System.PageReference|true|false
 09:38:36.309 (309153000)|VARIABLE_ASSIGNMENT|[42]|report|"/00OP0000000Jp3N?csv=1"|0x5ede6433
 09:38:36.309 (309170000)|STATEMENT_EXECUTE|[45]
 09:38:36.310 (310416000)|VARIABLE_SCOPE_BEGIN|[45]|attachment|Messaging.EmailFileAttachment|true|false
 09:38:36.310 (310654000)|VARIABLE_ASSIGNMENT|[45]|attachment|"common.api.soap.wsdl.EmailFileAttachment@5a8480ed"|0x312c7608
 09:38:36.310 (310671000)|STATEMENT_EXECUTE|[46]
 09:38:36.310 (310683000)|HEAP_ALLOCATE|[46]|Bytes:10
 09:38:36.310 (310743000)|STATEMENT_EXECUTE|[48]
 09:38:36.310 (310769000)|SYSTEM_METHOD_ENTRY|[48]|System.PageReference.getContent()
 09:38:40.061 (4061179000)|SYSTEM_METHOD_EXIT|[48]|System.PageReference.getContent()
 09:38:40.061 (4061307000)|STATEMENT_EXECUTE|[53]
 09:38:40.061 (4061332000)|HEAP_ALLOCATE|[53]|Bytes:8
 09:38:40.061 (4061396000)|STATEMENT_EXECUTE|[54]
 09:38:40.062 (4062321000)|VARIABLE_SCOPE_BEGIN|[54]|message|Messaging.SingleEmailMessage|true|false
 09:38:40.062 (4062508000)|VARIABLE_ASSIGNMENT|[54]|message|"common.api.soap.wsdl.SingleEmailMessage@5605f541"|0x2128aa86
 09:38:40.062 (4062525000)|STATEMENT_EXECUTE|[55]
 09:38:40.062 (4062644000)|HEAP_ALLOCATE|[55]|Bytes:4
 09:38:40.062 (4062722000)|SYSTEM_CONSTRUCTOR_ENTRY|[55]|<init>()
 09:38:40.062 (4062778000)|SYSTEM_CONSTRUCTOR_EXIT|[55]|<init>()
 09:38:40.062 (4062818000)|SYSTEM_METHOD_ENTRY|[55]|LIST<Messaging.EmailFileAttachment>.add(Object)
 09:38:40.062 (4062836000)|SYSTEM_METHOD_EXIT|[55]|LIST<Messaging.EmailFileAttachment>.add(Object)
 09:38:40.063 (4063046000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:40.063 (4063089000)|STATEMENT_EXECUTE|[56]
 09:38:40.063 (4063103000)|HEAP_ALLOCATE|[56]|Bytes:6
 09:38:40.063 (4063147000)|STATEMENT_EXECUTE|[57]
 09:38:40.063 (4063160000)|HEAP_ALLOCATE|[57]|Bytes:23
 09:38:40.063 (4063192000)|STATEMENT_EXECUTE|[58]
 09:38:40.063 (4063211000)|HEAP_ALLOCATE|[58]|Bytes:4
 09:38:40.063 (4063228000)|SYSTEM_CONSTRUCTOR_ENTRY|[58]|<init>()
 09:38:40.063 (4063255000)|SYSTEM_CONSTRUCTOR_EXIT|[58]|<init>()
 09:38:40.063 (4063281000)|SYSTEM_METHOD_ENTRY|[58]|LIST<String>.add(Object)
 09:38:40.063 (4063296000)|SYSTEM_METHOD_EXIT|[58]|LIST<String>.add(Object)
 09:38:40.063 (4063345000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:40.063 (4063372000)|STATEMENT_EXECUTE|[59]
 09:38:40.063 (4063413000)|HEAP_ALLOCATE|[59]|Bytes:4
 09:38:40.063 (4063462000)|SYSTEM_CONSTRUCTOR_ENTRY|[59]|<init>()
 09:38:40.063 (4063493000)|SYSTEM_CONSTRUCTOR_EXIT|[59]|<init>()
 09:38:40.063 (4063513000)|SYSTEM_METHOD_ENTRY|[59]|LIST<Messaging.SingleEmailMessage>.add(Object)
 09:38:40.063 (4063528000)|SYSTEM_METHOD_EXIT|[59]|LIST<Messaging.SingleEmailMessage>.add(Object)
 09:38:40.063 (4063570000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:40.063 (4063591000)|SYSTEM_METHOD_ENTRY|[59]|Messaging.sendEmail(LIST<Messaging.Email>)
 09:38:40.063 (4063704000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:40.095 (4095751000)|EMAIL_QUEUE|[59]|subject: Report, bccSender: false, saveAsActivity: true, useSignature: true, toAddresses: [user@citymedia.com], plainTextBody: The report is attached., 
 09:38:40.095 (4095970000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
 09:38:40.095 (4095995000)|SYSTEM_METHOD_EXIT|[59]|Messaging.sendEmail(LIST<Messaging.Email>)
 09:38:40.223 (4223309000)|CODE_UNIT_FINISHED|Exporter invoke(executeRpt)
 09:38:40.224 (4224422000)|VF_APEX_CALL|j_id0|{!executeRpt}|PageReference: none
 09:38:40.553 (4335699000)|CUMULATIVE_LIMIT_USAGE
 09:38:40.553|LIMIT_USAGE_FOR_NS|(default)|
   Number of SOQL queries: 0 out of 100
   Number of query rows: 0 out of 50000
   Number of SOSL queries: 0 out of 20
   Number of DML statements: 0 out of 150
   Number of DML rows: 0 out of 10000
   Number of code statements: 17 out of 200000
   Maximum heap size: 0 out of 6000000
   Number of callouts: 0 out of 10
   Number of Email Invocations: 1 out of 10
   Number of fields describes: 0 out of 100
   Number of record type describes: 0 out of 100
   Number of child relationships describes: 0 out of 100
   Number of picklist describes: 0 out of 100
   Number of future calls: 0 out of 10
 
 09:38:40.553|CUMULATIVE_LIMIT_USAGE_END
 
 09:38:40.335 (4335749000)|CODE_UNIT_FINISHED|VF: /apex/TestSendReport
09:38:40.335 (4335762000)|EXECUTION_FINISHED
 

 ....But the email never arrives.

 

When I just run the page (https://c.cs4.visual.force.com/apex/TestSendReport?csv=1)  it runs and send an email just fine.


Am I missing something?

 

Many Thanks for any insight

 

 

 

 

 

 

 

 

 

Hi,
Well, right on the heels of "Man"ish's question, here I am with an @future question...

I read that it's possible to schedule a report to run using @future with an HTTP callout, but I'm having absolutely no luck. Hoping someone has Ideas. All of the below seems to work, but I neve get the results emailed to me.

The email address and the report ID are stored in a Custom settings group down in the Exporter class...

 

The anonymous Apex:

 String s = '1 04 19 24 1 ?'; 
 Exporter  abc = new Exporter ();
 system.schedule('Report Job', s, abc);

 

The Schedulable class:

global class ReportExporter implements System.Schedulable {
    global void execute(SchedulableContext sc) {
    getmailReportOutput gem = new getmailReportOutput();
    gem.runReport();
    }
}

 

The class that does te HTTP callout to the  VF page that calls the class that generates and emails the report:

public class getmailReportOutput{
    
    public getmailReportOutput() {
        }
    
    public void runReport() {
        makeReportRequest();
        }
        
@future (callout=true)      
    public static void makeReportRequest()  {   
        ReportName__c mc = ReportName__c.getValues('ReportName');
        String strEmailAddr =  mc.RptEmail__c;
        URL xHost = System.URL.getSalesforceBaseUrl();
        String strHost =xHost.getHost();
        String requestUrl =  'https://' + strHost + '/apex/TestSendReport';
        HttpRequest req = new HttpRequest();
        req.setEndpoint(requestUrl);
        req.setMethod('GET');
        req.setHeader('Cookie','sid=' + UserInfo.getSessionId());
        String output = new Http().send(req).getBody();
        }
    }
    

 

The VF page that calls the class that generates the report and emails the CSV file:

<apex:page controller="Exporter" action="{!executeRpt}">
  <!-- Begin Default Content REMOVE THIS -->  
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

...And lastly, the class that does the actual work of generating the results and emailing them off:

 

public class Exporter {
    public static Boolean isTest;
    public static String strEmailAddr;
    
    void Exporter() {
        isTest = false;
        }
    
    public void execute    () {
        getmailReportOutput gem = new getmailReportOutput();
        gem.runReport();
        }
        
    public void setSendRpt(String locEmailAddr) {  
        isTest = false;
        strEmailAddr =  locEmailAddr;
        }
  
   public void setTest() {
        isTest = true;
        }

    public PageReference runThisPage() {
        ApexPages.PageReference report = new ApexPages.PageReference('/apex/TestSendReport');
        return report.setRedirect(false);
        }
        
             
    public void executeRpt() {
        System.debug('CALLING REPORT EXPORTER...');        
        ReportName__c mc = ReportName__c.getValues('ReportName');
        strEmailAddr =  mc.RptEmail__c;
        
        System.debug('ReportName:' +  mc.RptName__c);
        System.debug('EmailAddr:' + mc.RptEmail__c);
        integer a = 1;
        ApexPages.PageReference report = new ApexPages.PageReference( '/' + mc.RptName__c + '?csv=1');
         
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.csv');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] { strEmailAddr } );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );        
    }
 
}

 

If I just call the page, it all works great- all I ned to do is figure out how to schedule the page... but no luck.

 

Any help is appreciated.

 

Thanks

 

 

 

 

 

 

 

 

 

 

We would like to have a final estimate field by a total hours field which is different for each opportunity in order to input into the hourly rate field (weighted hourly rate calculation). Example $65,500 "final estimate" / 1,230 "total hours" = "$53.25 weighted hourly rate" we would like this field to auto populate once the input values have been inserted and make the input value fields mandatory should either one receive data. We would also like to have the field automatically update should one or both of the input values be changed and saved.

 

Thanks,

Carla

916-375-6700

I have a trigger code deployed that upon a set parameter, it will automatically convert a Lead to an Account with an Opportunity. What type of additional line of code would I need to add to enable these converted records be attached to existing Accounts rather than simply creating a net new record?

the following is from the documentation. let's say the opportunty.name is an externalid (unique) and let's say i have .csv file called c:\oppcommisionpercent.csv  that has columns of  name, commissionpercent. The y axis of the dashboard should a calculate the commission amount which would be the opportunity.amount * commissionpercent  which basically multiplies the commission% with the opportunity amount.  I think this is possible passing a JSON array into the <apex:/chart> component.. .been playing around but any ideas would be great

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_charting_example.htm

 

public class OppsController {

// Get a set of Opportunities

public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}

public List<Opportunity> getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
}
}

<apex:page controller="OppsController">
<apex:chart data="{!Opportunities}" width="600" height="400">
<apex:axis type="Category" position="left" fields="Name" title="Opportunities"/>
<apex:axis type="Numeric" position="bottom" fields="Amount" title="Amount"/>
<apex:barSeries orientation="horizontal" axis="bottom" xField="Name" yField="Amount"/>
</apex:chart>
<apex:dataTable value="{!Opportunities}" var="opp">
<apex:column headerValue="Opportunity" value="{!opp.name}"/>
<apex:column headerValue="Amount" value="{!opp.amount}"/>
</apex:dataTable>
</apex:page>

 

I've got myself a map like the following.

Map<Page1Task__c, List<Note__c>> this.taskNotes = new Map <Page1Task__c, List<Note__c>>();

 I'd like to represent one Page1Task and a few fields, followed by all of its notes and repeat for each PageTask sObject on a visualforce page. 

 

I found something similar to this, but I this won't work since I need to just iterate through each one and display it. Here's where I'm at now...

 

 

<apex:pageBlockTable id="results" value="{!taskNotes}" var="t" cellPadding="4" border="1">
        <apex:repeat value="{!taskNotes[t]}" var="n">
              <apex:column >
...
              </apex:column> 
        </apex:repeat> 
</apex:pageBlockTable>

 

Hello Helpers

 

 

does somebody know  hjow  to diplsy an Activex  controller in a visualforce page

 

I am thinking  on a custom button running a jscript  which instantiate the Activex  but I never seen somethinmg similar

 

I have no ide how to embedd the Activex  in the page  and which jScript method  to call to create the ActiveX object

 

any sample code  would be helpfull.  

 

 

Regards

Csaba 

Hi everyone,

Is that possible to remove None from a picklist?