• sf_evolution
  • NEWBIE
  • 100 Points
  • Member since 2012

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

I have a controller that creates a list and then the list is displayed in a pageblocktable.  For some reason one of the fields is not showing and I have no idea why.

here is the visualforce page:

<apex:pageblocktable value="{!LineItemList}" var="lil" border="0"  columnsWidth="60px, 200px, 200px" width="100%" >
<apex:column headerValue="Action">
<apex:commandButton value="X" />
</apex:column>
<apex:column headerValue="Serial #">
<apex:inputField value="{!lil.SerialNo__c}"/>
</apex:column>
<apex:column headerValue="Part #" >
<apex:inputField value="{!lil.Part_Number_2__c}"/>
</apex:column>
<apex:column headerValue="Ship To Address" >
<apex:inputField value="{!lil.Display_Address__c}"/>
</apex:column>
</apex:pageblocktable>

 Here is the controller:

public list<OrderLine__c> getLineItemList(){
	billA = [select Full_Address__c from Address__c where Account__c = :acct.id AND Default__c = true AND Type__c = 'Bill To'];
	shipA = [select Full_Address__c from Address__c where Account__c = :acct.id AND Default__c = true AND Type__c = 'Ship To'];    
	newLineItems = new list<OrderLine__c>();
	ol0 = new OrderLine__c();
	ol1 = new OrderLine__c();
	ol2 = new OrderLine__c();
	ol3 = new OrderLine__c();
	ol4 = new OrderLine__c();
	ol5 = new OrderLine__c();
	ol6 = new OrderLine__c();
	ol7 = new OrderLine__c();
	ol8 = new OrderLine__c();
	ol9 = new OrderLine__c();
	ol0.ShipToAddress__c = shipA.id;
	ol1.ShipToAddress__c = shipA.id;
	ol2.ShipToAddress__c = shipA.id;
	ol3.ShipToAddress__c = shipA.id;
	ol4.ShipToAddress__c = shipA.id;
	ol5.ShipToAddress__c = shipA.id;
	ol6.ShipToAddress__c = shipA.id;
	ol7.ShipToAddress__c = shipA.id;
	ol8.ShipToAddress__c = shipA.id;
	ol9.ShipToAddress__c = shipA.id;
	ol0.Display_Address__c = shipA.Full_Address__c;
	ol1.Display_Address__c = shipA.Full_Address__c;
	ol2.Display_Address__c = shipA.Full_Address__c;
	ol3.Display_Address__c = shipA.Full_Address__c;
	ol4.Display_Address__c = shipA.Full_Address__c;
	ol5.Display_Address__c = shipA.Full_Address__c;
	ol6.Display_Address__c = shipA.Full_Address__c;
	ol7.Display_Address__c = shipA.Full_Address__c;
	ol8.Display_Address__c = shipA.Full_Address__c;
	ol9.Display_Address__c = shipA.Full_Address__c;   
	newLineItems = new list<OrderLine__c>();
	newLineItems.add(ol0);
	newLineItems.add(ol1);
	newLineItems.add(ol2);
	newLineItems.add(ol3);
	newLineItems.add(ol4);
	newLineItems.add(ol5);
	newLineItems.add(ol6);
	newLineItems.add(ol7);
	newLineItems.add(ol8);
	newLineItems.add(ol9);
	system.debug('***** newLineItems *****'+newLineItems);
return newLineItems;
}

 Here is the debug log:

***** newLineItems *****(OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM}, OrderLine__c:{Display_Address__c=877n 8888s, dunesburry, Footah, foolah, 98745, ShipToAddress__c=a0SV00000014BTgMAM})

 the issue I have is that the Display_Address__c field does not display.  Any idea why?

I'm calling the webservice in curl like this:

 

curl "https://na12.salesforce.com/services/apexrest/****/profiledata?PARAM1=12345&PARAM2=DUMMY&LAST_SYNC_DATETIME=2012-07-22T09:00:00Z" -k -H 'Authorization: Bearer <SESSIONID> -H "X-PrettyPrint: 1"

 

where <SESSIONID> was obtained from calling UserInfo.getSessionId() from Execute Anonymous in Eclipse.

However it always fails with errorCode "INVALID_SESSION_ID" and message "Session expired or invalid".

 

Where am I going wrong?  I couldn't make sense of OAuth but I read in the docs you could just replace OAuth with Bearer and a sessionId for testing purposes.

 

Hi all,

 

I'm trying to build a custom button on a page layout for a custom object  that calls javascript that updates other fields on the page.  I defined the behavior as "execute javascript" and the Content Behavior as "OnClick Javascript".  The source is simple;

 

<script language="JavaScript">
try { {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} {!Appointment__c.Confirmed_Date__c}={!Appointment__c.ApptDate__c} ; {!Appointment__c.Confirmed_Time__c}={!Appointment__c.ApptTime__c} ; } catch(err){ alert(err); }
</script>

 

...But I keep on getting a popup that says "syntax error"  - help?

 

 

 

Wow- that's a heckuva subject line, but it basically defines my predicament.

 

I have a workflow (several, actually) that fires off after N days, and creates a task - that works fine.

 

But I check off the "Notify recipient" checkbox, and the email "From" address is set to me (the creator of the WFR) rather than the "default workflow user" -- this seems like a bug to me.  And it's a major hassle because I have CSR's responding to me rather than the default workflow user (which has a "noreply" email address).

 

The only fix I was able to come up with was to delete the entire set of rules, and actually log in as the default workflow user and re-create the lot of the (the workflows, that is).

 

Is there an easier way?  I don't see any way to set the user of the email address of the "From" line on the "Notify Recipient" feature of a task creation.

 

Thanks for any 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.

 

 

 

 

 

 

 

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- 

Subject pretty much says it all.

There is a cookie present on cs4.salesforce.com called "lastlist":

 

 

 

...But I can't seem to get to it in code- I have havascript on a VF page that is trying to find it, but it just doesn't show....

<apex:page standardController="Lead">
<apex:form >
<script>
function getCookie(c_name){
var i,x,y,ARRcookies=document.cookie.split(";");
alert('ARRcookies'+ARRcookies);
for (i=0;i<ARRcookies.length;i++){
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x=='lastlist') {
    alert('lastlist: '+unescape(y));
    return unescape(y);
    }
  }
}
</script>
        <apex:commandLink value="return:" onClick="getCookie('lastlist')"/>
    <apex:detail subject="{!Lead.Id}" relatedList="true" showchatter="true" inlineEdit="true" />
</apex:form>
</apex:page>

 

...The "lastlist" cookie just isn't there...

anyone have any ideas?

I also tried looking for it in a page controller extension but that didn't work either.

 

The whole reason I need to use this cookie is so I can get tbhe page view ID.

 

Tanks in advance

 

 

Hi all,

 

I have to definitively count the number of times a rep has read his/her particular leads...

I got the code working great, but I seem to be missing the "Back to List: Leads" link and

it's causing me to lose some goodwill with the CSRs.

 

I basically have a lead page override that looks like:

 

<apex:page standardController="Lead" extensions="LeadPageLoadCode" action="{!loadEvent}">

<apex:form >
    <apex:detail subject="{!Lead.Id}" relatedList="true" showchatter="true" inlineEdit="true" />
</apex:form>
</apex:page>

 

...And the LeadPageLoadCode is actually a bit of work, because I have to check if the lead is converted, owned by someone else, etc...  but FWIW, here it is;

public with sharing class LeadPageLoadCode {
    private final Lead Lead;   
    
    public LeadPageLoadCode (ApexPages.StandardController stdController){       
        System.debug('Entering Constructor...');
        this.Lead = (Lead) stdController.getRecord();
        }
        
     public PageReference loadEvent() {       
        PageReference leadPage = new ApexPages.StandardController(Lead).view(); 
        System.debug('Entering loadEvent...');
        String strLeadId  = this.Lead.Id;
        Id myId = UserInfo.getUserId();
        List<Lead> myLeads = [SELECT IsUnRead__c, OwnerId , IsConverted from Lead where Id = :strLeadId LIMIT 1];
        
        if(myLeads[0].IsConverted == true) {    // can't do anything....
            System.debug('Redirecting to  ViewConvertedLead');
            leadPage = new PageReference ('/p/lead/ViewConvertedLead/d?id='+myLeads[0].Id);
            return leadPage;
            }           
        
        if(myLeads.size() != 0 ) {  // we have work to do...
            if(myLeads[0].IsUnRead__c == null) {myLeads[0].IsUnRead__c = 0;}            
            if( myLeads[0].OwnerId == myId) {                
                if(myLeads[0].IsUnRead__c <= 0) {
                    System.debug('Lead.IsUnRead = 0');
                    myLeads[0].IsUnRead__c += 1;
                    update myLeads;                   
                    leadPage.setRedirect(True);
                    }
                 else {
                    System.debug('Lead.IsUnRead: '+myLeads[0].IsUnRead__c);
                    leadPage = new PageReference ('/apex/LeadPageAnchor');
                    }         
                 return leadPage;
                 }
            else {
                System.debug('Lead.IsUnRead: '+myLeads[0].IsUnRead__c);
                leadPage = new PageReference ('/apex/LeadPageAnchor');
                }                          
            }
        else {   // This is not the lead owner - do nothing
            System.DEBUG('This is not the lead owner - do nothing');
            leadPage = new PageReference ('/apex/LeadPageAnchor');            
            }
        return leadPage;    
        }
}

 

...I'm omittintg the "LeadPageAnchor" for brevity, but suffice it to say it's just the same thing as the anchor--- it just keeps the page from going into an infinite loop.   Also, this code only counts to 1 - but I fixed that elsewhere....

 

 

My problem is The "Back to List: Leads" link disappears.

 

Is there a way I can build this? it doesn't seem like I can get access to the Lead Page View ID on the view button override.

Any help is greatly appreciated.

 

 

Thanks!

 

 

 

 

Hi all,

I am updating a datatable from data that I receive from an external HTTP Callout API.

The only way I sem to be able to get the data to display on my VF page is if
I query for the external ID from a commandbutton on the page, and have the button
rerender the datatable.

What I would like is for the previous page to just call the desired page with the
customerID and have it render the datatable with the customer ID and be done with it.

Specifically, this works:

 

Controller-relevant code:

public class ListingIdFindController {

    public String strResponse { get; set; }
         String[] listListings = new List<String>();
         
         public class Listings {
             public String ListingID{get;set;}
             public String StreetID{get;set;}
             public String theURL{get;set;}
             public String PrimaryCategoryId{get;set;}
             public String PrimaryCategoryValue{get;set;}
             public String MOP{get;set;}
             public String MOPID{get;set;}
             }      
   [---]   
   
   public void getParameters() {
   
    public class ListingId {
         public String status;
         List<jsonCategories> existingBusinesses;
         List<jsonAccounts > activeBillingAccounts;
         List<jsonPrimaryCategories > primaryTags;
         }

   [---]
         String strTargetListing = ApexPages.currentPage().getParameters().get('CustId');
	 String endpoint = 'https://api-endpoint.com/salesforce/automation/api/lookups?';
	 endpoint += 'customerId=' + EncodingUtil.urlEncode(strTargetListing, 'UTF-8');                
	 request.setMethod('GET');
	 request.setEndPoint(endpoint);
	 System.debug('endpoint: ' + endpoint);

	 HttpResponse response = httpProtocol.send(request);
 	 String strResponse = response.getBody();
	
	 System.debug('strResponse : ' + strResponse );                
	 theListing = (ListingId ) JSON.deserialize(strResponse , ListingId.class);   

	//  -- [Fill-in class Listings with JSON-deserialized data]
	ListingValues = theListing;
	}	
}

 ... And my VF page just reads the public object

 

<apex:page controller="ListingIdFindController" id="ListingIdFindPage">
<apex:form id="ListingIdFindForm">
<apex:pageBlock Title="Search Listing By CID">
    <apex:inputText label="CID: "   value="{!strTargetListing}" />
    <apex:commandButton action="{!getParameters}" value="Go" id="FindListingsButton" rerender="detail_s,detail_p" />
</apex:pageBlock>

<apex:pageBlock Title="Listings Results-Please select a listing">
   <apex:pageBlockSection title="Listings" columns="3" >
      <apex:dataTable value="{!ListingValues}" var="list" id="detail_s" width="800px">
         <apex:column width="25%">
            <apex:facet name="header">Listing ID</apex:facet>
            <apex:outputText value="{!list.ListingID}"/>
         </apex:column>

         <apex:column width="40%">
            <apex:facet name="header">Address</apex:facet>
            <apex:outputText value="{!list.StreetId}"/>
         </apex:column>

         <apex:column width="10%">
            <apex:outputLink value="/{!list.theURL}">Click Here</apex:outputLink>
         </apex:column>
      </apex:dataTable>
   </apex:pageBlockSection>
   <apex:pageBlockSection Id="button_s">
       <apex:outputText value="{!strResponse}" />
       <br/>
   </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

My problem is that I woulk like for the "apex:commandButton" to go away, and just pass the "CustId"
to the controller from the VF page, and have the page render with the data from the HTTP callout directly.

All the examples I've seen seem to point to a rerender working under the pretext of re-querying
data once the datatable data is filled, but this obviously is a different case becayuse I'm
getting my data from an external API.

 

Is this possible?   I've tried putting the"getParameters()" call inside the constructor, but that didn't help.


Any help is appreciated.

 

 



 

 

 

 

 

Hi Everybody,

I'm missing something for a task that requires me to deserialize a JSON string. The string defines business types for many industries... 

 

And every parent insustry can have up to four (or maybe more) groups  of child sub-business types.

The basic format od the JSON is like this:

 

[
  {
    "tag_name": "Agriculture & Forestry", 
    "parent_tag_id": null, 
    "tag_id": 1, 
    "children": [
      {
        "tag_name": "Agricultural Services", 
        "parent_tag_id": 1, 
        "tag_id": 2, 
        "children": [
          {
            "tag_name": "Cotton Gins", 
            "parent_tag_id": 2, 
            "tag_id": 3
          }, 
          {
            "tag_name": "Crop Maintenance", 
            "parent_tag_id": 2, 
            "tag_id": 4
          }, 
...

    ]
  }, 
  {
    "tag_name": "Attorneys & Legal Services", 
    "parent_tag_id": null, 
    "tag_id": 204, 
    "children": [
      {
        "tag_name": "Attorneys", 
        "parent_tag_id": 204, 
        "tag_id": 205, 
        "children": [
          {
            "tag_name": "Anti-Trust Attorneys", 
            "parent_tag_id": 205, 
            "tag_id": 206
          }, 

 Etc. Etc...

In my code I defined the structure of the json hierarchy, and I'm reading the .json page OK, but I can't quite get the syntax of the
deserialize statement;

 

public class CategoryUtil {
     /*
      *   Define sub-class
      */  
     public with sharing class Cat_Tree {
        public String tag_name {get; set;}
        public integer parent_tag_id {get; set;}
        public integer tag_id {get; set;}
        
        public List<Cat_TreeChildren> TreeChildren {get; set;}

        public Cat_Tree(String f1, integer f2, integer f3) {
            tag_name = f1;
            parent_tag_id = f2;
            tag_id = f3;
            TreeChildren = new List<Cat_TreeChildren>();
            }                  
       }         
      public class Cat_TreeChildren {
            public String tag_name {get; set;}
            public integer parent_tag_id {get; set;}
            public integer tag_id {get; set;}
        
            public Cat_TreeChildren (String f1, integer f2, integer f3) {
               tag_name = f1;
               parent_tag_id = f2;
               tag_id = f3;
               }
        }        
        
    public CategoryUtil() {        
        getParameters();
        }
   
    public void getParameters () {
        Http httpProtocol = new Http();
        HttpRequest request = new HttpRequest();
        String endpoint = 'http://Externalbusiness.com/tags_hierarchy.json';

        request.setEndPoint(endpoint); 
        request.setMethod('GET');
   
        request.setHeader('Content-Type', 'application/json');
        HttpResponse response = httpProtocol.send(request);
        String strResponse = response.getBody();
        System.debug('HTTP strResponse: ' + strResponse);
        Type myType = Type.forName('Cat_Tree');
        
        //listCategories  =   Json.deserialize(strResponse, myType );    
        Cat_Tree cat_deserialize = (Cat_Tree)JSON.deserialize(strResponse , myType);
        System.debug('Cat_Tree: ' + cat_deserialize);
        }

 Basically, at the 

System.debug('HTTP strResponse: ' + strResponse);

Line I'm printing out my JSON string correctly,  but the next line:

 

Cat_Tree cat_deserialize = (Cat_Tree)JSON.deserialize(strResponse , myType);

Crashes with a "Attempt to de-reference a null object " error.

 

Any idea what I'm doing wrong?   Thanks in advance for any help.

 

 

 

 

 

 

 

 

Hi

 

Is it possible to add a field onto the opportunities that are displayed from the forecasts home page?

Specifically, I'd like to display the account name.  

 

I tried creating a formula field on the Opportunity record that dosplays "Account.Name" and adding that to the "All" opportunity listview, but it still doesn't show up.

 

Thanks in advance for any tip.

 

 

 

 

I know the Winter release is coming, and I'm assuming that has something to do with this error, but I get this error when trying to deploy code from Sandbox to Prod:

 

One or more components failed Version Compatibility Check.

This change set contains components that require the "26.0" or higher platform version. Please select an organization with a platform version of "26.0" or higher, or remove all incompatible components.

 

Does anyone know what I can do?

Thanks,

 

Something weird is happening...

I have a custom object that has a single integer counter field that's updated when a lead is inserted.

 

If records are inserted rapidly all records are inserted, but the integer counter is not updated.

This isn't the actual code, but it's indicative of what I'm trying to accomplish;

 

trigger leadAssign on Lead (before insert, after insert) {

     if (Trigger.isBefore && Trigger.isInsert) {
        for (Lead l : System.Trigger.new) {   // build keyset of all emails in lead(s)
	    CustomObject.Last_Assign__c++;
	    update CustomObject;
	    break;
	    }
	}
} // end of ATL Assignment
 

 

If I insert one lead at a time via the API it work fine, but if I stack up the requests asychronously, CustomObject.Last_Assign__c doesn't get updated... 

 

Any help is greatly appreciated.

 

 

 

 

I guess the Subject says it.

 

Is there a way to set up a page view so that it automaticaly updates, so that our CSR's don't have to constantly hit the refresh button?

 

 

Hi all,

 

I need to write a joined report showing sales pipeline info from lead to lead-conversion,  but when the lead is converted it seems like there is no access from the opportunity to the converted lead.

 

I guess I could add a custom lookup field to the opportunity and write trigger code to insert the leadID on lead conversion, but that doesn't solve the  problem of what to do with the thousands of converted leads we already have.  

 

Is there another solution to this?  

Are there hidden audit fields on opportunities that I can have SFDC turn on?

 

EDIT:

I found the field   "ConvertedOpportunityId"  in the lead, but I need to use it as a common field to join two blocks on a joined format report

Does anyone know how to do this?

 

Thanks for any ideas


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.

 

 

  • March 21, 2013
  • Like
  • 0

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);

}




}
}

  • February 01, 2013
  • Like
  • 0

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.

  • January 29, 2013
  • Like
  • 0

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>

 

  • January 11, 2013
  • Like
  • 0

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 

  • January 09, 2013
  • Like
  • 0
Hi everyone,

Is that possible to remove None from a picklist?