• Ryan Greene
  • NEWBIE
  • 240 Points
  • Member since 2015

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 21
    Questions
  • 58
    Replies
Hello,

I want to send Visualforce page as pdf in email for e-sign using Adobe EchoSign When clicked on command button on Visualforce page. This Visualforce page contains data from multiple objects. How can I send this page for signature using Adobe EchoSign? Please help asap.
I created a WFR formula that automatically inputs/updates (project expiration) Date fields based on the picklist value that is selected. I also created a time-based WFR that sends email alerts 30, 60,90 days prior to that Date. Is there a way that I can set the email alerts to only go to a specific group of users based on the picklist value that is selected?

Example:
IF Picklist Value = Project A or Project B or Project C
    Send the 30 day (60 or 90 depending on the expiration Date field) email alert to User 1 and  User 2 ONLY

IF Picklist Value = Project D or Project E or Project F
      Send the 30 day (60 or 90 depending on the expiration Date field) email alert to User 3 and User 4 ONLY

This is my current Time Based Workflow Rule:
Description: Notifies management 30/60/90 days prior to Project#1 Exp Date
Rule Criteria: Project: Project #1 Exp Date NOT EQUAL TO null

Time-Dependent Workflow Actions
Email Alert Alert 90 days before Project#1 Exp Date
Email Alert Alert 60 days before Project#1 Exp Date
Email Alert Alert 30 days before Project#1 Exp Date
I would like my SavePDF action to save the French and English PDF visualforce pages I have.  I've tried using an if/else statment but couldn't get it to work so I thought I would just try to have BOTH attached no matter what, but I'm having trouble getting that to work too...

Is this possible?  Here is what I've tried based on my research:
 
public pageReference savePDF(){

PageReference pagePdf = 
          new PageReference('/apex/Residential_Order_Form_PDF');
		  new PageReference('/apex/Residential_Order_Form_PDF_French');
          pagePdf.getParameters().put('id', idVal);
          Blob pdfPageBlob;
          pdfPageBlob = pagePdf.getContentAsPDF();
Should I be stating it differently?
 
I don't think there is an easy way to do this, but I thought I'd ask.  Thanks!
Hi all,

I hope that somebody answers my question as I am making efforts to describe what my problem is. I am trying to solve this without success.
I would like to autopopulate two lookup fields when I press the button New on a related list.

Matriculaci_n__c is the object where the related list Títulos is to find. The object is T_tulo__c.
I would like to add a button New on the related list Titulos, in order to get to the detail page where I can find two lookups autopopulated with the Postgraduate Course (Programa_acad_mico_1__c) and the Name of the Applicant (Cuenta_de_Alumno__c) mentioned in the Matriculaci_n__c object.

For this I built the following Apex Code:
 
public with sharing class SobreescribeTituloNuevo {
    
 public SobreescribeTituloNuevo(ApexPages.StandardController controller) {
    }
    public Pagereference onLoad(){
        PageReference newPage = new PageReference('/a10/e?');
        String TituloId;
        for(String keyValue : ApexPages.currentPage().getParameters().keySet()){
            if(!keyValue.contains('override') ){
                newPage.getParameters().put(keyValue, ApexPages.currentPage().getParameters().get(keyValue));
                if(keyValue.contains('retURL')) {
                  TituloId = ApexPages.currentPage().getParameters().get('retURL');
                }
            }
        }
        system.debug(TituloId);
        TituloId =  TituloId.removeStart('/');
        if(TituloId.length() >= 15) {
        Matriculaci_n__c objMatriculacion = [Select Id, Programa_acad_mico_1__c, Programa_acad_mico_1__r.Name, Cuenta_de_Alumno__c, Cuenta_de_Alumno__r.Name from Matriculaci_n__c where Id =: TituloId];
            newPage.getParameters().put('00N3E000000QaTd_lkid', objMatriculacion.Programa_acad_mico_1__c);
            newPage.getParameters().put('00N3E000000QaTd', objMatriculacion.Programa_acad_mico_1__r.Name);
			newPage.getParameters().put('00N3E000000XmQ3_lkid', objMatriculacion.Cuenta_de_Alumno__c);
			newPage.getParameters().put('00N3E000000XmQ3', objMatriculacion.Cuenta_de_Alumno__r.Name);
            newPage.getParameters().put('nooverride','1');
        }
        else {
            newPage.getParameters().put('nooverride','0');
        }
        return newPage.setRedirect(true);
    }
}
My Visualforce page looks like this:
 
<apex:page standardController="T_tulo__c" extensions="SobreescribeTituloNuevo" action="{!onLoad}">
</apex:page>
When I try to create a button for the related list Títulos, the Content field doesn't display anything, does anybody know why?. I already tried with many of the supposed solutions given in the internet, but none works for me, and I don't know where else do I have to change something or where is the mistake here.

User-added image
The IDs are here on this page fictitious.

As you see the Content field is not shown, can please somebody help me? :(.

 
Hello,
I have an apex Emthod which calls a VF Page as a PDF and inserts the PDF to a record. Right now it is working as long as I don't call any Contact info for use in the PDF. As you can see in the VF Page I am trying to access the First Name of the Contact. The Error Log below I started where it starts looking at the PDF, then through where the Fatal Error comes in. The VF Page and Apex, I put in some comments in line. I have a feeling running the Method as static void has something to do with the error? Any suggestions much appreciated!!
Thanks,
Ryan
Error Log:
13:02:11.430 (5727412584)|STATEMENT_EXECUTE|[95]
13:02:11.430 (5727438344)|HEAP_ALLOCATE|[95]|Bytes:16
13:02:11.430 (5727493424)|VARIABLE_SCOPE_BEGIN|[95]|pdfPage|System.PageReference|true|false
13:02:11.430 (5728228256)|VARIABLE_ASSIGNMENT|[95]|pdfPage|"/apex/contactpdf"|0x70a80652
13:02:11.430 (5728244984)|STATEMENT_EXECUTE|[96]
13:02:11.430 (5728274749)|SYSTEM_METHOD_ENTRY|[96]|System.PageReference.getParameters()
13:02:11.430 (5728318848)|HEAP_ALLOCATE|[96]|Bytes:0
13:02:11.430 (5728348187)|SYSTEM_METHOD_EXIT|[96]|System.PageReference.getParameters()
13:02:11.430 (5728361632)|HEAP_ALLOCATE|[96]|Bytes:2
13:02:11.430 (5728411478)|SYSTEM_METHOD_ENTRY|[96]|Map<String,String>.put(Object, Object)
13:02:11.430 (5728453867)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4
13:02:11.430 (5728478883)|SYSTEM_METHOD_EXIT|[96]|Map<String,String>.put(Object, Object)
13:02:11.430 (5728490327)|STATEMENT_EXECUTE|[97]
13:02:11.430 (5728519858)|VARIABLE_SCOPE_BEGIN|[97]|pdfBody|Blob|false|false
13:02:11.430 (5728539640)|VARIABLE_ASSIGNMENT|[97]|pdfBody|null
13:02:11.430 (5728561572)|METHOD_ENTRY|[99]||System.Test.isRunningTest()
13:02:11.430 (5728593511)|METHOD_EXIT|[99]||System.Test.isRunningTest()
13:02:11.430 (5728603950)|STATEMENT_EXECUTE|[101]
13:02:11.430 (5728606748)|STATEMENT_EXECUTE|[102]
13:02:11.430 (5728618628)|SYSTEM_METHOD_ENTRY|[102]|System.PageReference.getContentAsPDF()
13:02:11.430 (5797457576)|FATAL_ERROR|Internal Salesforce.com Error
VF Page:
<apex:page standardController="Contact" applyBodyTag="false" renderAs="pdf">
<!--CSS Styling Removed-->
        <html>
            <body>
                 <!-- Breaks when trying to pull Contact First Name. If I do not pull the first name Apex and VF Page run perfectly -->
                I, {!Contact.FirstName} acknowledge blah blah blah
Apex:
public class EchoSignRG{
    public ApexPages.StandardController Controller;
    public EchoSignRG(ApexPages.StandardController Controller){
        this.Controller = Controller;}
    @InvocableMethod
    public static void SendPDF(List<ID> conid){
        Lead L = [SELECT Id,Name,Street,City,State,PostalCode,ConvertedContactId,ConvertedOpportunityId,LeadSource,ConvertedAccountId FROM Lead WHERE Id =: conid];
        Contact con1 = [SELECT Id,AccountId,email,Firstname,lastname FROM Contact WHERE Id =: L.ConvertedContactId];
//SOME OTHER CODE HERE
            pageReference pdfPage = Page.ContactPDF;
            pdfPage.getParameters().put('id',con1.Id);
            blob pdfBody;
            if(Test.isRunningTest()){
                pdfBody = blob.valueOf('Unit.Test');
            }else{
                pdfBody = pdfPage.getContentAsPDF();}
//Fatal Error LINE ABOVE
            attachment pdfFile = new attachment();
            pdfFile.isPrivate = false;
            pdfFile.body      = pdfBody;
            pdfFile.parentId  = agreementRec1.id;
            pdfFile.Name      = agreementRec1.Name+'.pdf';
            
            insert pdfFile;



 
Hello all,
I am having trouble with an HTTP Callout Test. I have a Trigger which sends it's info to the Class which houses the Http Callout. To Test for an Http Callout I followed the Apex Dev documentation (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm) where I create two Test classes, one sends Mock Http info and the other calls the Mock info. I beleive the problem is in the passing the "String ldid" from the Trigger to the Class. Trigger/Class/Tests below. Any ideas on how to solve this? Thanks!
Trigger:
String ldid;       
if(Trigger.isBefore){
      if(Trigger.isUpdate || Trigger.isInsert){
          for(Lead ld : Trigger.new){
              if(ld.IsConverted == TRUE && ld.Segment__c == 'Large Group'){
                  ldid = ld.Id;
                  CallApply.basicAuthCallout(ldid);
Class:
public class CallApply {
    public static HttpResponse basicAuthCallout(String ldid){
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://test');
        req.setMethod('POST');
        String body = '{"LeadId":"'+ldid+'"}';
        req.setHeader('Content-Type','application/json');  
        req.setBody(body);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        return res;
    }
}
Test1:
@isTest
global class Test_callApply1 implements HttpCalloutMock {
    global HTTPResponse respond(HttpRequest req) {
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type','application/json');
        res.setBody('{"example":"test"}');
        res.setStatusCode(200);
        return res;
    }
}
Test2:
@isTest
private class Test_callApply2 {
     @isTest static void testCallout() {
        Test.setMock(HttpCalloutMock.class, new Test_callApply1());
        //create Lead to pass value 'ldid'
        Lead ld = new Lead();
        ld.FirstName = 'testRyan';
        ld.LastName = 'testGreene';
        ld.email = 'testingtrigger1@test.com';
        ld.Company = 'testCompanyasdasdasdeyjhlnn';
        insert ld;
        String ldid = ld.id;
         
        HttpResponse res = CallApply.basicAuthCallout(ldid);
        
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"example":"test"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
    }
}

 
Hello All,
I wrote a simple Trigger to not allow deletion of a specific record. Also, I wrote a Test Class with 100% code coverage in dev. When attempting change set I am receiving a Code Coverage Failure, with 0% code coverage. What is happening? I have tried the Change Set as both Default, and only run the Test related to my Trigger. I am deploying both in the same Change Set. All suggestions appreciated!
Thanks, Ryan
Trigger:
trigger callapplyTrigger on Lead (before update, before insert,before delete){
    if(Trigger.isDelete){
        for (Lead l : [SELECT Id,Email FROM Lead WHERE Email = 'testingtrigger1@test.com' AND Id IN :Trigger.old]){
            Trigger.oldMap.get(l.Id).addError(
                'Cannot delete this Lead.');
        }
    }
}
Test Class:
@isTest
public class Test_callApply {
    @isTest static void TestDelete(){
        Lead lead = new Lead(Segment__c='Small Group',Email='testingtrigger1@test.com',
                             FirstName='testRyan',LastName='testGreene',Status='New',
                          Company='testCompany',City='Orlando',State='FL',LeadSource='Event');
        insert lead;
        
        Test.startTest();
        Database.DeleteResult result = Database.delete(lead,false);
        Test.stopTest();

        System.assert(!result.isSuccess());
        System.assert(result.getErrors().size() > 0);
        System.assertEquals('Cannot delete this Lead.',result.getErrors()[0].getMessage());
    }
}

 
Hello,
I created an Apex Trigger to create a Note in the ContentNote upon creation of the record, and the trigger works great and copies the information perfectly with no strange value. Partial code for the Trigger:
for(Lead lds : Trigger.new){
        ContentNote cnt = new ContentNote();
        cnt.Content = Blob.valueof(lds.Sales_Notes__c);
        cnt.Title = 'Creation Note';
Now I created another code to transfer existing "Sales Notes" to the ContentNote. This is an Apex Class and works off a VF button. It also transfers the note and displays the text in the "Text Preview" appropriately, but when the ContentNote is opened it displays Korean/Chineese sysmbols. WHAT IS GOING ON?? Screenshots and Apex Class code below:
TextPreview WorksWHAT?!?!
 
for(Lead lds : lead){
            ContentNote cnt = new ContentNote();
            cnt.Content = Blob.valueof(lds.Sales_Notes__c);
            cnt.Title = 'Creation Note';

 
Hello,
I created a very simple trigger to add a Note when a Lead is created. The Note is not getting added, what am I doing wrong? (Code below) Is it not working because the Lead is not yet created? With an After Insert this shouldn't matter though. Notes are turned on and are working to manually create them.
Thanks,
Ryan
trigger AddNote on Lead (after insert) {
	List<Note> addnte = new List<Note>();
        for(Lead lds : Trigger.new){
            Note addedntes = new Note();
            addedntes.ParentId = lds.Id;
            addedntes.Body = lds.Sales_Notes__c;
            addedntes.Title = 'Creation Note';
            addnte.add(addedntes);
        }
    if(addnte.size()>0){
        insert addnte;
    }
}

 
public class ProposalEC {
    public List<Lead> Ld {get;set;}
    public List<Component__c> Com {get;set;}
    public List<User> us {get;set;}
    public Id getid {get;set;}{
        getid = ApexPages.currentPage().getParameters().get('id');}    
    public ProposalEC(){
        Ld = [SELECT Id,OwnerId,UW_Facility_Size__c,Max_Advance_Rate__c,City__c,State_Company__c,Zip_Code__c, Street__c, Entity__c, Company,
              FirstName, LastName FROM Lead WHERE Id =: getid];
        Com = [SELECT Id,Aging_Collection_Every_X_Days__c,Aging_Collection_Beyond_X_Days__c,Fee_Aging_Collection__c,Fee_Funds_Usage_Daily__c,
               Fee_Inventory_Monitoring__c,Fee_Invoice_Purchase__c,Advance_Rate_Inventory__c,Inventory_Sublimit__c,
               Name,Fee_Field_Appraisal__c,Fee_Field_Exam__c,Fee_Proposal__c,Fee_Due_Diligence__c,Special_Pricing__c
               FROM Component__c WHERE RecordTypeId = '0123F0000008XdC' AND Active_Component__c = True AND Related_Lead__c =: Ld[0].Id];
        us = [SELECT FirstName, LastName FROM User WHERE Id =: Ld[0].OwnerId];
    }
 
<apex:page controller="ProposalEC" renderAs="pdf">
    <apex:image url="{!$Resource.Logo}" style="left;" width="15%" height="15%"></apex:image>
    
    <apex:outputPanel rendered="{!Ld[0].Entity__c == '1'}">  
        <html>
            Working Capital Proposal
        </html>
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!Ld[0].Entity__c == '2'}">  
        <html>
           Working Capital Proposal
        </html>
    </apex:outputPanel>
    <apex:outputText value="{0,date,MMMM dd, yyyy}">
        <apex:param value="{!TODAY()}" />
    </apex:outputText>
    <html>
        For: {!Ld[0].Company}<br/>
        {!Ld[0].Street__c}<br/>
        {!Ld[0].City__c}, {!Ld[0].State_Company__c} {!Ld[0].Zip_Code__c}<br/>          
        {!Com[0].Name}<br/><br/><br/><br/>
        {!Ld[0].FirstName},<br/><br/>
        I'm pleased to present {!Ld[0].Company} ("Client") with the following terms for a financing facility (the "Facility").<br/><br/>
        <b>Facility Size:</b> ${!IF(Ld[0].UW_Facility_Size__c < 1000, TEXT(ROUND(Ld[0].UW_Facility_Size__c,0)), 
        IF(Ld[0].UW_Facility_Size__c < 1000000, TEXT(FLOOR(ROUND(Ld[0].UW_Facility_Size__c,0) /1000)) 
        & ',' & RIGHT(TEXT(ROUND(Ld[0].UW_Facility_Size__c,0)), LEN(TEXT(ROUND(Ld[0].UW_Facility_Size__c,0))) - LEN(TEXT(FLOOR(ROUND(Ld[0].UW_Facility_Size__c,0) /1000)))), 
        IF(Ld[0].UW_Facility_Size__c < 1000000000, TEXT(FLOOR(ROUND(Ld[0].UW_Facility_Size__c,0) /1000000)) 
        & ',' & MID(TEXT(ROUND(Ld[0].UW_Facility_Size__c,0)), 1 + LEN(TEXT(1 + FLOOR(ROUND(Ld[0].UW_Facility_Size__c,0) /1000000))),3) 
        & ',' & RIGHT(TEXT(ROUND(Ld[0].UW_Facility_Size__c,0)), LEN(TEXT(ROUND(Ld[0].UW_Facility_Size__c,0))) - LEN(TEXT(FLOOR(ROUND(Ld[0].UW_Facility_Size__c,0) /1000)))), 
        NULL)))}.<br/><br/>
        <b>Advance Rate:</b> Up to {!Ld[0].Max_Advance_Rate__c}% on Client’s eligible accounts receivable.<br/>
    </html>
    <apex:outputPanel id="ARI" rendered="{!Com[0].Advance_Rate_Inventory__c != null}">  
        <html>
            <b>Advance Rate Inventory:</b> The lesser of 1) 65% of Net Orderly Liquidation Value as determined by an Inventory Appraiser acceptable to {!Ld[0].Entity__c} and 2) 50% of Eligible A/R and 3) the Inventory Sublimit, 
            ${!IF(Com[0].Inventory_Sublimit__c < 1000, TEXT(ROUND(Com[0].Inventory_Sublimit__c,0)), 
            IF(Com[0].Inventory_Sublimit__c < 1000000, TEXT(FLOOR(ROUND(Com[0].Inventory_Sublimit__c,0) /1000)) 
            & ',' & RIGHT(TEXT(ROUND(Com[0].Inventory_Sublimit__c,0)), LEN(TEXT(ROUND(Com[0].Inventory_Sublimit__c,0))) - LEN(TEXT(FLOOR(ROUND(Com[0].Inventory_Sublimit__c,0) /1000)))), 
            IF(Com[0].Inventory_Sublimit__c < 1000000000, TEXT(FLOOR(ROUND(Com[0].Inventory_Sublimit__c,0) /1000000)) 
            & ',' & MID(TEXT(ROUND(Com[0].Inventory_Sublimit__c,0)), 1 + LEN(TEXT(1 + FLOOR(ROUND(Com[0].Inventory_Sublimit__c,0) /1000000))),3) 
            & ',' & RIGHT(TEXT(ROUND(Com[0].Inventory_Sublimit__c,0)), LEN(TEXT(ROUND(Com[0].Inventory_Sublimit__c,0))) - LEN(TEXT(FLOOR(ROUND(Com[0].Inventory_Sublimit__c,0) /1000)))), 
            NULL)))}.
        </html>
    </apex:outputPanel>
    <apex:outputPanel id="IPF" rendered="{!Com[0].Fee_Invoice_Purchase__c != null}">  
        <html>
            <b>Invoice Purchase Fee:</b> {!Com[0].Fee_Invoice_Purchase__c}% on the gross amount of all invoices submitted to {!Ld[0].Entity__c} for funding.
        </html>
    </apex:outputPanel>    
    <apex:outputPanel id="IMF" rendered="{!Com[0].Fee_Inventory_Monitoring__c != null}">  
        <html>
            <b>Inventory Monitoring Fee:</b> {!Com[0].Fee_Inventory_Monitoring__c}%.<br/><br/>
            <b>Inventory Advance Formula:</b> The lesser of 1) 65% of Net Orderly Liquidation Value as determined by an Inventory Appraiser acceptable and 2) 50% of Eligible A/R and 3) the Inventory Sublimit.
        </html>
    </apex:outputPanel>

Hello,
I have a VF Page rendered as a PDF and the page populates all of my needed information except for one field; Max_Advance_Rate__c, should be around line 32 in the VF code. It is a percent field, and I do have other percent fields displayed and working on the current VF Page. Any suggestions? VF and Class below
 
I continue to receive error messages when trying to invoke Apex when a record is created. My Lead object has a related object called Additional Owners which are basically additional Contacts, so when the Lead is Converted I have a Trigger which takes the Additional Owners and creates Contact Records for them. Then I have an invocable method which sends PDFs to the newly created Contact. The invocable method is run from a Process Builder which runs when that new Contact is created. Each time I test converting a Lead Additional Owner, I recieve the error "Error:Apex trigger ContactfrmAO caused an unexpected exception, contact your administrator: ContactfrmAO: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3013F00000005Bx. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: []: Trigger.ContactfrmAO: line 17, column 1"

The trigger ContactfrmAO is the trigger to create a Contact from the Additional Owner object. Line 17 is the insert of the Contact. The Flow error is for the Process Builder invoking the Apex.

It seems I am trying to do too many funcitons all at once. Any thoughts on how to make this work?
I have a seemingly simple Test I wrote but when run it receives the error: Methods defined as TestMethod do not support getContent call. I do not have a .getContent call in my Test. I have narrowed down the error to most likely be the line "conid.add(con.Id);". I'm think the .add() when called acts like a .getContent()? Any thoughts on a way around the call?
Thank you,
Ryan
@isTest
public class Test_EchoSign2 {
    static testmethod void testechosign(){
    	Account ac = new Account(RecordTypeId = [SELECT Id, SobjectType, Name FROM Recordtype WHERE Name = 'Prospect/Client' AND SobjectType = 'Account' LIMIT 1].Id);
    	ac.Name = 'TestAcnt';
    	ac.Type = 'Prospect';
    	insert ac;
    
		Contact con = new Contact(RecordTypeId = [SELECT Id,SObjectType,Name FROM RecordType WHERE Name = 'Prospect/Client' AND SobjectType = 'Contact' LIMIT 1].Id);
		con.LastName = 'testLastName';
    	con.AccountId = ac.Id;
        con.Email = 'ryan.greene@outlook.com';
	    con.LeadSource = 'Unknown';
        insert con;
 
        List<Id> conid = new List<Id>();
        conid.add(con.Id);
		EchoSign.SendPdf(conid);
    }
}

 
Hello,
I am writing a test for an @InvocableMethod and for some reason I keep getting an error that says Invalid Type: SendPdf. Code below, any help is appreciated!!
Controller
public with sharing class EchoSign {
    private ApexPages.StandardController standardController;
    public EchoSign(ApexPages.StandardController standardController){
        this.standardController = standardController;}

@InvocableMethod
    public static void SendPdf(List<ID> conid){
        
    List<Contact> con = [SELECT Id, AccountId, Name FROM Contact WHERE Id =: conid LIMIT 1];  
        
        pageReference pdfPage = Page.ContactPDF;
        pdfPage.getParameters().put('Id',con[0].Id);
        blob pdfBody;
        pdfBody = pdfPage.getContentAsPDF();

//creation of Adobe Sign Agreement and Attachment here
}
}
Test
@isTest
public class Test_EchoSign2 {
    static testMethod void testechosign(){
    	Account ac = new Account(RecordTypeId = [SELECT Id, SobjectType, Name FROM Recordtype WHERE Name = 'Prospect/Client' AND SobjectType = 'Account' LIMIT 1].Id);
    	ac.Name = 'TestAcnt';
    	ac.Type = 'Prospect';
    	insert ac;
    
		Contact con = new Contact(RecordTypeId = [SELECT Id,SObjectType,Name FROM RecordType WHERE Name = 'Prospect/Client' AND SobjectType = 'Contact' LIMIT 1].Id);
		con.LastName = 'testLastName';
    	con.AccountId = ac.Id;
	    con.LeadSource = 'Unknown';
        insert con;
        
        Test.startTest();
        
        PageReference ContactPDF = Page.ContactPDF;
        ContactPDF.getParameters().put('Id',con.Id);
        Test.setCurrentPage(ContactPDF);
        
        SendPdf pdf = new SendPdf();
    }
}


 
Hello,
I have a button on my page which runs a VF Page with an extension to my controller. It works to press the button and it produces the EchoSign Agreement as directed. However, the page it goes to when I click the button is a blank page. I would like to redirect it to the Id of the record I just created upon pressing the button. Basic outline of code below. So how can I get a void method to redirect to the ID of the record it just created?
public void SendPdf(){
//reference PDF Creator VF Page
pageReference pdfPage = Page.ContactPDF;
pdfPage.getParameters().put('Id',getid);
blob pdfBody;
pdfBody = pdfPage.getContentAsPDF();
          
// Build Echosign agreement record
echosign_dev1__SIGN_Agreement__c agreementRec = new echosign_dev1__SIGN_Agreement__c();
agreementRec.Name = 'Credit Info Release for: ';
//other variables entered here
insert agreementRec;

// insert the pdf as an attachment
attachment pdfFile = new attachment();
pdfFile.isPrivate = false;
pdfFile.body = pdfBody;
pdfFile.parentId = agreementRec.id;
pdfFile.Name = 'Agreement.pdf';
insert pdfFile;
}

 
Hello,
I have not written Apex Tests before (I probably should have) and I am running into an error each time I run the test, but there is no error on the page. Test Class below and I am receiving the error on line 6: Error Message - System.NullPointerException: Attempt to de-reference a null object  Stack Trace - Class.Test_UploadAttachmentController.testattach
 
@isTest
private class Test_UploadAttachmentController {
    static testMethod void testattach(){
        Document__c doc = new Document__c(Document__c = 'Aging', RecordTypeId = [SELECT Id, SobjectType, Name FROM Recordtype WHERE Name = 'Request' AND SobjectType = 'Document__c' LIMIT 1].Id);
        insert doc;
        UploadAttachmentController controller = new UploadAttachmentController(new ApexPages.StandardController(doc));
        
        controller.fileName = 'Unit Test Attachment Body';
        controller.fileBody = Blob.valueOf('Unit Test Attachment Body');
        controller.processUpload();
        
        LIST<Attachment> attch = [SELECT Id, Name FROM Attachment WHERE parent.id =: doc.Id];
        System.assertEquals(1, attch.size());
    }
}

 
I currently have a Hyperlink from a custom object "Document" to a VF page. This hyperlink is displayed on the related list on the Lead, Opp, and some other custom objects. So the VF Page can be accessed from any of the records related to the Document record. The issue I am running into is how to set the return URL. I can set the Return URL ID based on each related record but how can I tell which record the user just accessed the VF Page from?
Hyperlink formula: HYPERLINK("/apex/AttachDoc?id="& Id &"&retURL=%2F"& Lead__r.Id ,"Upload Docs Here","_self")
So the formula above would only return the user to the Lead, but what if they actually accessed the link from the Opp or one of the other custom objects?
Hello,
I am trying to create two records when a Lead hits a certain point, then have those two new records associated to one another. The Lead will create one Underwriting record, then can create several Issues related to the Underwriting record it just created. I just started adding the create Issue records to the code and I know the first part works that creates a single UW record from the Lead. Just need to resolve relating the new Issues back to the UW record. Trigger below:
trigger SubmitUW on Lead (after update) {
    List<Underwriting__c> uw = new List<Underwriting__c>();
    List<Issue__c> i = new List<Issue__c>();
    Set<Id> UWId = new Set<Id>();
    for(Lead l : Trigger.new){
        if(l.Create_UW__c == TRUE){
            Underwriting__c u = new Underwriting__c();
            u.Lead__c = l.Id;
            //Add all fields below which need to be mapped from the Lead to the UW
            //format as follows - "u.UnderwritingFieldAPIName = l.LeadFieldAPIName;"
            u.City__c = l.City__c;
            u.Industry__c = l.Industry;
            //Adds all fields above to the compiled List
            uw.add(u);
            UWId.add(u.Id);
        }
        if(uw.size()>0)
        insert uw;
        
        if(l.Collateral__c == True){
            Issue__c is = new Issue__c();
            is.Underwriting__c = UWId;
        }
    }
}
My error is currently on "is.Underwriting__c = UWId;" with error: Illegal assignment from Set<Id> to Id
also not sure if the line "UWId.add(u.Id);" sets the Id properly

Thanks for your help!
 
Hello,
I am having difficulty adding a number to a set, then once it is set how do I add 1 to that number?

Code below; I receive error on line 3 of: void add(Decimal) from the type Set<Integer>
and error on line 11 of: void valueOf(Set<Integer>) from the type assign, which is directly related to line 3 not being set
Set<Integer> assignid = new Set<Integer>();
    for(Lead lead : [SELECT AssignIDDateTime__c, Assignment_ID__c FROM Lead WHERE AssignIDDateTime__c != null ORDER BY AssignIDDateTime__c DESC LIMIT 1]){
        assignid.add(lead.Assignment_ID__c);
    }
    
    for(Lead l : Trigger.new){
        if(l.Status == 'Underwriting'){
	        if(l.AssignIDDateTime__c == null){
            	l.Assignment_ID__c = decimal.valueOf(1);
            }else{
                l.Assignment_ID__c = decimal.valueOf(assignid) + decimal.valueOf(1);
            }
        }

    }
Thank you!
I tried deploying this Trigger to my production this morning. It is a simple trigger to convert any names to Propper case, first and last. It seems like another APEX Class is interfeering with the deployment. The error points to a managed package I am not able to edit. Any ideas on how to get around this error? 

Full Error: 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Proper: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Proper: line 5, column 1: [] 
Stack Trace: Class.dlrs.RollupService.testHandler: line 277, column 1 Class.dlrs_LeadTest.testTrigger: line 11, column 1

APEX Trigger:
trigger Proper on Lead (before insert) {
  for(Lead l : Trigger.new){
    if(l.FirstName != null)
      l.FirstName =  l.FirstName.subString(0 ,1).ToUpperCase() + l.FirstName.subString(1);
      l.LastName =  l.LastName.subString(0 ,1).ToUpperCase() + l.LastName.subString(1);
  }
}

 
Hello,
I am creating a code which checks the input Account Name for any other duplicate Names in the system and will post an error. I have the code working if I use ".contains()" (LINE 13), but I want to use exact value instead, and ".equals()" does not seem to work at all.
Please help!
trigger Dupe on Account (before insert, before update) {
    set<String> setName = new set<String>();
    set<String> ExistName = new set<String>();
        for (Account a : Trigger.new){
            setName.add(a.Name);
        }
        for (Account a : [SELECT Name FROM Account WHERE Name IN : setName]){
            ExistName.add(a.Name);
        }
    List <Duplicate__c> dup = new List <Duplicate__c>();
//    if (Trigger.isInsert || Trigger.isUpdate)
        for (Account acc : Trigger.new){
            if(ExistName.equals(acc.Name)){
                acc.Name.adderror('This Name already exists');
Thanks!
Ryan
Hello,
I am working on updating a field in my custom object based on the value of another field. I was able to get the field to update with no conditional statement but once I add the 'if' the field no longer updates properly. I've tried several different queries and I'm not sure what I have wrong. Any help appreciated!!
Thanks


<apex:page standardController="Web_Links__c">
   <apex:includeScript value="/soap/ajax/30.0/connection.js"/>
   <script type="text/javascript">
        result = sforce.connection.query("Select Status__c from Web_Links__c");
        records = result.getArray("records");
        if(records.Status__c == 'New'){
            var object = new sforce.SObject('Web_Links__c');
            object.Id = "{!Web_Links__c.Id}";
            object.RecordCount__c = {!EFI_Web_Links__c.RecordCount__c} + 1;
            var result = sforce.connection.update([object]);
        }
   </script>
</apex:page>
I am trying to get a Status field to update when two other fields equal. I am not getting any errors with my code, however it does not seem to be working properly. Please take a look and let me know your thoughts!
Thank you,
Trigger

trigger Read on Web_Links__c (before update){
    StatusRead.Read(Trigger.new);
}


Class

public class StatusRead {
    public static void Read(List<Web_Links__c> WI){
        Web_Links__c WL = [SELECT status__c FROM Web_Links__c];
            if(WL.Owner_ID__c == WL.Last_user_to_view_record__c){
                WL.status__c = 'Read';
                update WL;
           }
    }
}

 
This is a basic code to send emails through a VF page for a custom object and to include attachments from your computer. In every other sense it works great, it just wont accept large attachments.

Has anyone found a good solution for this error. I have been reading a lot of posts and testing different methods but nothing seems to work for my code. I re-wrote it a couple different times trying to find a different way but it seems the attachments still get written to the "view state" which is giving the error. How can I get around it?
 
Class

public class sendEmail {
    public String subject {get; set; }
    public String body { get; set; }
    public Attachment att {get;set;}
    public List<Attachment> attList {get;set;}
    private final Web_Links__c WebInquiry;

    public sendEmail() {
        WebInquiry = [SELECT Email__c, Full_Name__c, Subject__c, Message__c, CreatedDate FROM Web_Links__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];
        attList = new List<Attachment>();
        att = new Attachment();
        subject = 'RE: ' + WebInquiry.Subject__c;
        body = '\r\r\r\r' + '--------------- Original Message ---------------\n'+ '------ Received ' + WebInquiry.CreatedDate.format() + ' ------\n' + WebInquiry.Message__c;
    }

    public Web_Links__c getWebInquiry() {
        return WebInquiry;
    }

    public void upload(){
        if(att.name == null){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please Select File Path First.'));
        }else{
            att.OwnerId = UserInfo.getUserId();
            attList.add(att);
            att = new Attachment();
        }
    }
    
    public PageReference cancel(){
        return new PageReference('/' + WebInquiry.Id);
    }
        
    public PageReference send(){
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        List<Messaging.EmailFileAttachment> mailAttList = new List<Messaging.EmailFileAttachment>();
        String addresses;
        addresses = WebInquiry.Email__c;
        String[] toAddresses = addresses.split(':', 0);
        email.setSubject(subject);
        email.setToAddresses(toAddresses);
        email.setTemplateId('00X2A000001brMu');
        email.setHtmlBody(body);
        for(Attachment att1 : attList){
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
            efa.setBody(att1.body);
            efa.setFileName(att1.name);
            mailAttList.add(efa);
        }
        email.setFileAttachments(mailAttList);
        email.setWhatID(WebInquiry.id);
        email.setSaveAsActivity(true);
        email.setBccSender(true);
                
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

        return new PageReference('/' + WebInquiry.Id);
    }
}
 
VF Page

<apex:page controller="sendEmail">
    <apex:messages />
    <apex:pageBlock title="To: {!WebInquiry.Full_Name__c} {!WebInquiry.Email__c}">
        <apex:form >
            <apex:outputLabel value="Subject" for="Subject"/>:<br />     
            <apex:inputText value="{!subject}" id="Subject" maxlength="80" size="55"/>
            <br /><br />
            <apex:outputLabel value="Message" for="Body"/>:<br />     
            <apex:inputTextarea value="{!body}" id="Body"  rows="10" cols="80"/>           
            <br /><br />
            Attachment:<apex:inputFile value="{!att.body}" fileName="{!att.name}"/>
                <apex:commandButton title="Upload" action="{!upload}" value="Upload"/><br/>
                <apex:repeat value="{!attList}" var="att">
                    {!att.Name}<br/>
                </apex:repeat>            
            <br /><br />
            <apex:commandButton value="Send Email" action="{!send}" /> &nbsp;&nbsp;
            <apex:commandButton value="Cancel" action="{!cancel}" />
        </apex:form>
    </apex:pageBlock>
</apex:page>

 
I am creating a simple trigger to update the Status field if the field 'Last user to view record' equals the Owner ID of the record and the Status currently equals 'New'. The 'Last user to view record' field is a formula which pulls the current Users ID. (So if the User ID matches the Owner ID the status will change to 'Read') What seems to be wrong?
Thanks for your help!
Ryan
trigger Read on Web_Links__c (before update) 
{
OwnerId From Web_Links__c];
    for(Web_Links__c WI : Trigger.new ){
        if(WI.Status__c = 'New'){
            if(WI.Last_user_to_view_record__c = WI.OwnerId){
                WI.Status__c = 'Read';
            }
        }
    }
}

 
Hello,
I have an apex Emthod which calls a VF Page as a PDF and inserts the PDF to a record. Right now it is working as long as I don't call any Contact info for use in the PDF. As you can see in the VF Page I am trying to access the First Name of the Contact. The Error Log below I started where it starts looking at the PDF, then through where the Fatal Error comes in. The VF Page and Apex, I put in some comments in line. I have a feeling running the Method as static void has something to do with the error? Any suggestions much appreciated!!
Thanks,
Ryan
Error Log:
13:02:11.430 (5727412584)|STATEMENT_EXECUTE|[95]
13:02:11.430 (5727438344)|HEAP_ALLOCATE|[95]|Bytes:16
13:02:11.430 (5727493424)|VARIABLE_SCOPE_BEGIN|[95]|pdfPage|System.PageReference|true|false
13:02:11.430 (5728228256)|VARIABLE_ASSIGNMENT|[95]|pdfPage|"/apex/contactpdf"|0x70a80652
13:02:11.430 (5728244984)|STATEMENT_EXECUTE|[96]
13:02:11.430 (5728274749)|SYSTEM_METHOD_ENTRY|[96]|System.PageReference.getParameters()
13:02:11.430 (5728318848)|HEAP_ALLOCATE|[96]|Bytes:0
13:02:11.430 (5728348187)|SYSTEM_METHOD_EXIT|[96]|System.PageReference.getParameters()
13:02:11.430 (5728361632)|HEAP_ALLOCATE|[96]|Bytes:2
13:02:11.430 (5728411478)|SYSTEM_METHOD_ENTRY|[96]|Map<String,String>.put(Object, Object)
13:02:11.430 (5728453867)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4
13:02:11.430 (5728478883)|SYSTEM_METHOD_EXIT|[96]|Map<String,String>.put(Object, Object)
13:02:11.430 (5728490327)|STATEMENT_EXECUTE|[97]
13:02:11.430 (5728519858)|VARIABLE_SCOPE_BEGIN|[97]|pdfBody|Blob|false|false
13:02:11.430 (5728539640)|VARIABLE_ASSIGNMENT|[97]|pdfBody|null
13:02:11.430 (5728561572)|METHOD_ENTRY|[99]||System.Test.isRunningTest()
13:02:11.430 (5728593511)|METHOD_EXIT|[99]||System.Test.isRunningTest()
13:02:11.430 (5728603950)|STATEMENT_EXECUTE|[101]
13:02:11.430 (5728606748)|STATEMENT_EXECUTE|[102]
13:02:11.430 (5728618628)|SYSTEM_METHOD_ENTRY|[102]|System.PageReference.getContentAsPDF()
13:02:11.430 (5797457576)|FATAL_ERROR|Internal Salesforce.com Error
VF Page:
<apex:page standardController="Contact" applyBodyTag="false" renderAs="pdf">
<!--CSS Styling Removed-->
        <html>
            <body>
                 <!-- Breaks when trying to pull Contact First Name. If I do not pull the first name Apex and VF Page run perfectly -->
                I, {!Contact.FirstName} acknowledge blah blah blah
Apex:
public class EchoSignRG{
    public ApexPages.StandardController Controller;
    public EchoSignRG(ApexPages.StandardController Controller){
        this.Controller = Controller;}
    @InvocableMethod
    public static void SendPDF(List<ID> conid){
        Lead L = [SELECT Id,Name,Street,City,State,PostalCode,ConvertedContactId,ConvertedOpportunityId,LeadSource,ConvertedAccountId FROM Lead WHERE Id =: conid];
        Contact con1 = [SELECT Id,AccountId,email,Firstname,lastname FROM Contact WHERE Id =: L.ConvertedContactId];
//SOME OTHER CODE HERE
            pageReference pdfPage = Page.ContactPDF;
            pdfPage.getParameters().put('id',con1.Id);
            blob pdfBody;
            if(Test.isRunningTest()){
                pdfBody = blob.valueOf('Unit.Test');
            }else{
                pdfBody = pdfPage.getContentAsPDF();}
//Fatal Error LINE ABOVE
            attachment pdfFile = new attachment();
            pdfFile.isPrivate = false;
            pdfFile.body      = pdfBody;
            pdfFile.parentId  = agreementRec1.id;
            pdfFile.Name      = agreementRec1.Name+'.pdf';
            
            insert pdfFile;



 
Hello, 

I am having trouble getting my test class to work with my after update trigger. When I run my test it is showing 0% code coverage. Can anyone help me to understand why it is not working?

Here is the trigger code:
trigger FUS_UGGR_Application_Submitted on TargetX_SRMb__Application__c (After Update) {
	
    For (TargetX_SRMb__Application__c A : Trigger.New) {
    
    //Update Submitted Application Contact record to "Applicant"
    String ContactId = Trigger.newMap.get(A.ID).TargetX_SRMb__Contact__c;
    String New_Stage = Trigger.newMap.get(A.ID).TargetX_SRMb__Stage__c;
    String Old_Stage = Trigger.oldMap.get(A.ID).TargetX_SRMb__Stage__c;
    String App_Type = Trigger.newMap.get(A.ID).TargetX_SRMb__Application_Type__c;
        
    Contact C = [select id from Contact where id = :contactid];
    
 	IF(New_Stage <> Old_Stage && New_Stage == 'Submitted' && App_Type <> 'Undergraduate Non-Degree Post Secondary'){
    C.UGGR_Student_Stage__c = 'Applicant';
               	
    Update C;
            
        }        
    }
}

Here is my test class:
@isTest
public class FUS_Test_UGGR_App_Submit {

   //Perform Tests
    static testMethod void ValidateUGGRAppSubmit() 
    {

    Contact c = new Contact(
        FirstName = 'Test', 
        LastName = 'Test'
    );
    Insert c;
   
    TargetX_SRMb__Application__c a = new TargetX_SRMb__Application__c(
        TargetX_SRMb__Contact__c = c.Id, 
        TargetX_SRMb__Application_Type__c = 'Undergraduate',
        TargetX_SRMb__Stage__c = 'In Progress'
    );
    
    Insert a;
    
    Test.StartTest();
    	a.TargetX_SRMb__Stage__c = 'Submitted';
    	Update a;
    Test.stopTest();
    }
}

 
We received some emails from info@salesforcedevs.com in last few days stating that there is developer script exception from our company. It gives us the org ID but we are not able to identify the salesforce org based on org iD. Is there a way to identify username based on the org id. Already asked this to support but they redirected us here.

Org Id: 00D28000000sd3n
  • February 16, 2018
  • Like
  • 0
Hi,

I'm trying to update a phone field conditionally, depending on what the Division is. This IF and ISPICKVAL doesn't seem to be working. Do you see an issue?
Perhaps I'm not sure when to use brackets vs parenthesis. 

Thanks!

/a3l/e?retURL=%2F{!Account.Id}&
&CF00N1h000000PTrn={!Account.Name}
&00N1h000000PTru={!Account.BillingCity}
&00N1h000000PTrr={!Account.BillingStreet}
&00N1h000000PTrx={!Account.BillingCountry}
&00N1h000000PTsi={!Account.BillingPostalCode}
&00N1h000000PTsZ={!Account.BillingStateCode}
&00N1h000000PTrt={!IF(
{!ISPICKVAL(!Account.Division__c, "Quad/Graphics Logistics"){!Account.Phone},
{!Account.Main_Phone_Text__c},
{!Account.Phone})}
&00N1h000000PTsF={!Account.Fax}
Hello All,
I wrote a simple Trigger to not allow deletion of a specific record. Also, I wrote a Test Class with 100% code coverage in dev. When attempting change set I am receiving a Code Coverage Failure, with 0% code coverage. What is happening? I have tried the Change Set as both Default, and only run the Test related to my Trigger. I am deploying both in the same Change Set. All suggestions appreciated!
Thanks, Ryan
Trigger:
trigger callapplyTrigger on Lead (before update, before insert,before delete){
    if(Trigger.isDelete){
        for (Lead l : [SELECT Id,Email FROM Lead WHERE Email = 'testingtrigger1@test.com' AND Id IN :Trigger.old]){
            Trigger.oldMap.get(l.Id).addError(
                'Cannot delete this Lead.');
        }
    }
}
Test Class:
@isTest
public class Test_callApply {
    @isTest static void TestDelete(){
        Lead lead = new Lead(Segment__c='Small Group',Email='testingtrigger1@test.com',
                             FirstName='testRyan',LastName='testGreene',Status='New',
                          Company='testCompany',City='Orlando',State='FL',LeadSource='Event');
        insert lead;
        
        Test.startTest();
        Database.DeleteResult result = Database.delete(lead,false);
        Test.stopTest();

        System.assert(!result.isSuccess());
        System.assert(result.getErrors().size() > 0);
        System.assertEquals('Cannot delete this Lead.',result.getErrors()[0].getMessage());
    }
}

 
I am not an Apex developer.  I fumbled my way through creating a trigger in the sanbox to update data on the OpportunityLineItem.  I now need in production and have discovered I need it to go through testing?  Can someone help by providing steps to get this quickly tested and deployed to production?

trigger SetSyndicatedRevenueSchedule on OpportunityLineItem (before insert) {
    List<OpportunityLineItemSchedule> itemschedule = new List<OpportunityLineItemSchedule>();
    for (OpportunityLineItem o: Trigger.new)
    {
      if (o.Product_Subscription__c == False)
      {
        // o.Description = 'Hello World';
        o.ServiceDate = o.Report_Selling_Date__c;
        
        itemschedule.clear();
        // itemschedule = [Select id, ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId =: o.Id Order by ScheduleDate ASC];
        itemschedule = [Select ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId =: o.Id Order by ScheduleDate ASC];
        System.Debug('Test: ' + itemschedule);
        
        for (OpportunityLineItemSchedule rs: itemschedule)
        {
            rs.ScheduleDate = o.ServiceDate;
            update itemschedule;
        }
      }
    }
}

 
I havae spent almost a day trying to update a particular value for an entire list but everything I have tried so far has not worked.

I thought that the contents of an input field would be automatically passed to the controller as long the get and set methods for the respective object are set. In my case, I have a list of budgets and the idea is to either update a single one or all of them at once. Neither of these are working.

Below is my VF page:
<apex:page standardController="Budget__c" extensions="MerchandisingBudgetExtension">
    <apex:pageBlock title="Merchandising Budget">
        <b>Manager <i>{!$User.FirstName}</i></b>
        
        <apex:form>
            <apex:commandButton value="Reset My Team's Budget" />
            <apex:commandButton value="Update Allocated Budget" action="{!updateAll}"/>
        </apex:form>
        
        <apex:pageBlockTable value="{!budgetList}" var="budget">
            <apex:column headerValue="KAM Name" value="{!budget.Key_Account_Manager__r.Name}" />
            <apex:column headerValue="Allocated">
                <apex:form >
                    <apex:inputField value="{!budget.Allocated__c}"/>
                </apex:form>                
            </apex:column>    
            <apex:column >
                <apex:form id="all">
                    {!budget.Id}
                    <apex:commandButton value="Update" action="{!updateBudget}">
                    </apex:commandButton>
                </apex:form>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
And here is the respective controller:
 
public class MerchandisingBudgetExtension {
    
    public List<User> kamList { get; set; }
    public List<Budget__c> budgetList { get; set; }
    
    public MerchandisingBudgetExtension(ApexPages.StandardController controller){
        kamList = getKAMs();
        budgetList = new List<Budget__c>();
        
        for (User kam : kamList){
            Budget__c budget = getCurrentBudget(kam);
            budgetList.add(budget);
        }
    }
    
    // returns a list of KAMs for currently logged manager
    private List<User> getKAMs(){
        List<User> kamList = [SELECT Id, Name 
                              FROM User 
                              WHERE KAM_Manager__c = :UserInfo.getUserId()
                              ORDER BY Name ASC];
        return kamList;
    }
    
    // returns the current budget for a KAM
    private Budget__c getCurrentBudget(User kam){
        List<Budget__c> budgetList = [SELECT Date_assigned__c, Allocated__c, Total__c, Remaining__c, Used__c, 
                                      Key_Account_Manager__r.Name, Key_Account_Manager__r.Country 
                              FROM Budget__c
                              WHERE Key_Account_Manager__r.Name = :kam.Name
                              ORDER BY Date_assigned__c DESC];
        return budgetList.get(0);                
    }
    
    public PageReference save(){
        update budgetList;
        return null;
    }
    
    public void updateBudget(){
    }
    
}
I am first trying to get the updateAll() method to work first. I figured a simple update statement to the budgetList would be enough. However, what is happening instead is a page refresh every time I click on Update Allocated Budget button. What am I missing here? Thanks!
 
I have a batch job that takes a Salesforce Report and emails an Excel file to a group of addresses. The users are not Salesforce users. The batch job is working perfectly but when the email goes out it shows ALL the email addresses in the To field. Is there a way to hide the email addresses so that it shows on the receipents address but still sends to everyone in the list?
Hi All,

I wrote a class method for sending a single email message in my staging environment and the expected default behaviour of being saved as an activity worked. Moving to production, the saving as activity failed. Moreover, I can execute the code as anonymous apex and it saves as activity in the prod org. Here is the method:
 
public with sharing class EmailUpdateController {

	public static void sendTemplateEmail(String templateId, String whoId, String whatId) {
		Messaging.reserveSingleEmailCapacity(1);				
		Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
		email.setUseSignature(false);	
		email.setTemplateId(templateId);
		email.setTargetObjectId(whoId);
		email.setWhatId(whatId);
		List<Messaging.SendEmailResult> results = Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{email});
		Boolean returnValue = true;
		for (Messaging.SendEmailResult er : results) {
			System.debug(er.isSuccess());
			if(!er.isSuccess()) {
				System.debug(er.getErrors());
				returnValue = false;
			}
		}
		System.debug('Success was '+returnValue);
		
	}

}

This method works fine in staging and also running this in the dev console in production works.

Running code in Developer Console

I get activity as expected
Activity on Opportunity
When running the method however, eg: 
EmailUpdateController.sendTemplateEmail('00X0I000001dmpUUAQ', '00328000015yPZXAA2', '0060I00000R9fIMQAZ');

No activity is saved.  

Appreciate your help. I've been pulling my hair out with this.
Hello,

I want to send Visualforce page as pdf in email for e-sign using Adobe EchoSign When clicked on command button on Visualforce page. This Visualforce page contains data from multiple objects. How can I send this page for signature using Adobe EchoSign? Please help asap.
Hello,
I created a very simple trigger to add a Note when a Lead is created. The Note is not getting added, what am I doing wrong? (Code below) Is it not working because the Lead is not yet created? With an After Insert this shouldn't matter though. Notes are turned on and are working to manually create them.
Thanks,
Ryan
trigger AddNote on Lead (after insert) {
	List<Note> addnte = new List<Note>();
        for(Lead lds : Trigger.new){
            Note addedntes = new Note();
            addedntes.ParentId = lds.Id;
            addedntes.Body = lds.Sales_Notes__c;
            addedntes.Title = 'Creation Note';
            addnte.add(addedntes);
        }
    if(addnte.size()>0){
        insert addnte;
    }
}

 
I created a WFR formula that automatically inputs/updates (project expiration) Date fields based on the picklist value that is selected. I also created a time-based WFR that sends email alerts 30, 60,90 days prior to that Date. Is there a way that I can set the email alerts to only go to a specific group of users based on the picklist value that is selected?

Example:
IF Picklist Value = Project A or Project B or Project C
    Send the 30 day (60 or 90 depending on the expiration Date field) email alert to User 1 and  User 2 ONLY

IF Picklist Value = Project D or Project E or Project F
      Send the 30 day (60 or 90 depending on the expiration Date field) email alert to User 3 and User 4 ONLY

This is my current Time Based Workflow Rule:
Description: Notifies management 30/60/90 days prior to Project#1 Exp Date
Rule Criteria: Project: Project #1 Exp Date NOT EQUAL TO null

Time-Dependent Workflow Actions
Email Alert Alert 90 days before Project#1 Exp Date
Email Alert Alert 60 days before Project#1 Exp Date
Email Alert Alert 30 days before Project#1 Exp Date
Hi I am trying to drag and drop the files into my Custom Object.i.e Inline Vf Page.I can select multiple files but i am unable to drag and drop files in "Internet Explorer".But It works in Chrome.I tried the below code.Can YouPlease help me .Thanks
Visual Force Page--->
<apex:page standardController="Account__C" extensions="AttachmentActionFunction">
<script type='text/javascript'>



 var newWin=null;
 function openLookupPopup()
 {
  var url="/apex/docutype/";

  alert('$$$$$$$$$$'+ur1);
  newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');



    }

 function closeLookupPopup()
 {
    if (null!=newWin)
    {
       newWin.close();
    }  
 }



var maxStringSize = 6000000;
var attachmentList;
var j;
function uploadFiles()
{
    input = document.getElementById('fileinput');
    attachmentList = input.files;
    if(j == undefined) 
    j = 0;   
    var file;
    if(j < attachmentList.length)
    {
        file = attachmentList[j];
     var name = file.name;
        var reader = new FileReader();  
        reader.onload = function(e) {  
         var attachmentbodybase64 = window.btoa(reader.result)
            console.log(attachmentbodybase64.length);
            if(attachmentbodybase64.length > maxStringSize )
            alert("File size is too large to handle");
            else
            {
                j++;
                saveFileAF(attachmentbodybase64, name);
            }
        }
         reader.readAsDataURL(file);
    }
    else
    {
        console.log('this is end');
        var url = window.location.origin + '/'+"{!$CurrentPage.parameters.Id}";
        console.log(url);
        window.location.href = url;
    }

 }
</script>

<script>
function test(){

var url="/apex/docutype";

newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
    console.log('$$$$$$$$$$'+ur1);
    if (window.focus) 
  {
   newWin.focus();
  }

     return false;


}
</script>

<apex:form >
  <input type= "file" Id= "fileinput"  multiple="multiple" />
     <apex:commandButton value="Upload" onclick="test(); return false;" />
    <apex:actionFunction name="saveFileAF" 
         action="{!saveFile}" oncomplete="test()" rerender="form"  status="uploading">
        <apex:param name="base64File" value="" assignTo="{!base64}"/>
        <apex:param name="fileName" value="" assignTo="{!fileName}"/>
    </apex:actionFunction>
    <apex:actionStatus id="uploading" >
        <apex:facet name="start" >
            <img src="/img/loading.gif" />                    
  </apex:facet>
 </apex:actionStatus>    
</apex:form>
</apex:page>

Apex Controller
public class AttachmentActionFunction {

 public transient String base64;
    public account__C Ins;

   public List<Attachment> mulfiles{get;set;}

public Pagereference gotonewpage()
{     
     PageReference pageRef = Page.AttachmentActionFunction;
     pageRef.getParameters().put('msg','success');
     return PageRef;
}   

    public AttachmentActionFunction() {
     mulfiles=new List<Attachment>();

    }



    public String getBase64()
    {
        return base64;
    }
    public void setbase64(String base64)
    {
        this.base64 = base64;
    }
    public String fileName {get; set;}
    public AttachmentActionFunction(ApexPages.StandardController std)
    {
        Ins = (Account__C)std.getRecord();
    }
    public void saveFile()
    {
        Attachment a = new Attachment(parentId = Ins.id, Body =  EncodingUtil.base64Decode(base64), name = fileName);

        mulfiles=new List<Attachment>();


        mulfiles.add(a);
        //insert a;

    }



     public PageReference saveinline() {
        return null;
    }


}

 
Hi Experts,

I have added a button "opt-out" in the email template.
This email will be sent to people and when they click the opt-out button, then the stage in opportunity should change to opt out.
How can do this

Please help.
Thanks.