• Ken Seaney
  • NEWBIE
  • 65 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies

I have a flow that has multiple date input fields on flow screens that are used in our community. They are the standard date field elements in the flow designer (not custom components). The problem is that if a person types in a wrong date format  (i.e. 1/1/201 ) it crashes the flow. 
Error from email:
FIELD_INTEGRITY_EXCEPTION: date fieldname.: invalid date: Thu Jan 01 00:00:00 GMT 201.

I have tried to use validation for the field in Flow Designer but cannot seem to get a formula that works for a date field. Keep getting syntax errors.

I have tried both REGEX date formulas and LEN to try to enforce a date format that it will accept - (mm/dd/yyyy) in the user interface, but not getting anywhere.

Hi there,

I have created a VF page to display an image attachment from a Contact on a custom object. The VF page and controller are working, but I am having trouble with the test class for it. The problem I am having is that I am not sure how to reference the current record in the test. 

Controller:

Public Class displayImageExtension {

    public Fund_Relationships__c currentRecord {get; set;} 
    
    public displayImageExtension(ApexPages.StandardController controller) {
        currentRecord = [SELECT Id, Contact__c FROM 
                         Fund_Relationships__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];    
    }
    
    public String getFileId() {
        String fileId = '';
        List<Attachment> attachedFiles = [select Id FROM Attachment WHERE parentId =:currentRecord.Contact__c AND Name LIKE '%Sig%' order By LastModifiedDate DESC limit 1];
        if (attachedFiles.size() == 0){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'No signature image found'));
            return null;
      } 
        if( attachedFiles != null && attachedFiles.size() > 0 ) {
            fileId = attachedFiles[0].Id;
        }
   
        return fileId;    
    }
}

VF Page

<apex:page standardController="Fund_Relationships__c" extensions="displayImageExtension">
<apex:form >
    <apex:image url="/servlet/servlet.FileDownload?file={!FileId}" width="300" rendered="{!IF(FileId !="",True,False)}"/>
<apex:pageMessages id="showmsg"></apex:pageMessages>
</apex:form>
</apex:page>
 

Test Class (23% coverage)

@isTest
private class TestdisplayImageExtension {
    static testMethod void MyTest(){
        Account myaccount = new Account (name='Test');
		insert myaccount;
        
        Contact mycontact = new Contact (firstname='Billy', lastname='Baggins');
        insert mycontact;
        
        Attachment attach = new Attachment();
  		attach.Name = 'Signature_File';
  		Blob bodyBlob = Blob.valueOf('Testing Body of Attachment');
  		attach.body = bodyBlob;
  		attach.parentId = mycontact.id;
  		insert attach;
        
        Fund__c myfund = new Fund__c();
        myfund.Name = 'Test Fund';
        myfund.Account__c = myaccount.id;
        myfund.Entity__c = 'SIF';
        myfund.Fund_Type__c = 'Social Enterprise Loan';
        myfund.Type__c = 'Term Loan';
        myfund.Status__c = 'New';
        myfund.Open_Date__c = date.today();
        insert myfund;
        
        Fund_Relationships__c fundauth = new Fund_Relationships__c();
        fundauth.Contact__c = mycontact.id;
        fundauth.Fund__c = myfund.id;
        fundauth.Role__c = 'General';
        fundauth.Role_Status__c = 'Current';
        fundauth.Start_Date__c = date.today();
        insert fundauth;
        
        displayImageExtension controller = new displayImageExtension(new ApexPages.StandardController(fundauth));
        
List < Attachment > attachedFiles = [select id, name from Attachment where parent.id = : mycontact.id];
 System.assertEquals(1, attachedFiles.size());
        
String newAttachId = controller.getFileId();
 System.assertEquals(newAttachId, attachedFiles[0].Id);
    }
}
 

Any help with this would be greatly appreciated!

-- Ken
 

Hi there,

I have created a VF page to display an image attachment from a Contact on a custom object. The VF page and controller are working, but I am having trouble with the test class for it. The problem I am having is that I am not sure how to reference the current record in the test. 

Controller:

Public Class displayImageExtension {

    public Fund_Relationships__c currentRecord {get; set;} 
    
    public displayImageExtension(ApexPages.StandardController controller) {
        currentRecord = [SELECT Id, Contact__c FROM 
                         Fund_Relationships__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];    
    }
    
    public String getFileId() {
        String fileId = '';
        List<Attachment> attachedFiles = [select Id FROM Attachment WHERE parentId =:currentRecord.Contact__c AND Name LIKE '%Sig%' order By LastModifiedDate DESC limit 1];
        if (attachedFiles.size() == 0){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'No signature image found'));
            return null;
      } 
        if( attachedFiles != null && attachedFiles.size() > 0 ) {
            fileId = attachedFiles[0].Id;
        }
   
        return fileId;    
    }
}

VF Page

<apex:page standardController="Fund_Relationships__c" extensions="displayImageExtension">
<apex:form >
    <apex:image url="/servlet/servlet.FileDownload?file={!FileId}" width="300" rendered="{!IF(FileId !="",True,False)}"/>
<apex:pageMessages id="showmsg"></apex:pageMessages>
</apex:form>
</apex:page>
 

Test Class (23% coverage)

@isTest
private class TestdisplayImageExtension {
    static testMethod void MyTest(){
        Account myaccount = new Account (name='Test');
		insert myaccount;
        
        Contact mycontact = new Contact (firstname='Billy', lastname='Baggins');
        insert mycontact;
        
        Attachment attach = new Attachment();
  		attach.Name = 'Signature_File';
  		Blob bodyBlob = Blob.valueOf('Testing Body of Attachment');
  		attach.body = bodyBlob;
  		attach.parentId = mycontact.id;
  		insert attach;
        
        Fund__c myfund = new Fund__c();
        myfund.Name = 'Test Fund';
        myfund.Account__c = myaccount.id;
        myfund.Entity__c = 'SIF';
        myfund.Fund_Type__c = 'Social Enterprise Loan';
        myfund.Type__c = 'Term Loan';
        myfund.Status__c = 'New';
        myfund.Open_Date__c = date.today();
        insert myfund;
        
        Fund_Relationships__c fundauth = new Fund_Relationships__c();
        fundauth.Contact__c = mycontact.id;
        fundauth.Fund__c = myfund.id;
        fundauth.Role__c = 'General';
        fundauth.Role_Status__c = 'Current';
        fundauth.Start_Date__c = date.today();
        insert fundauth;
        
        displayImageExtension controller = new displayImageExtension(new ApexPages.StandardController(fundauth));
        
List < Attachment > attachedFiles = [select id, name from Attachment where parent.id = : mycontact.id];
 System.assertEquals(1, attachedFiles.size());
        
String newAttachId = controller.getFileId();
 System.assertEquals(newAttachId, attachedFiles[0].Id);
    }
}
 

Any help with this would be greatly appreciated!

-- Ken
 

I have been receiving an error and I am stuck on where to go to resolve this. the error is "Challenge Not yet complete... here's what's wrong: 
The Account record home page may not be activated."

I cant seem to figure out what to do! HELP
Hi,
I am not able to understand the below question correctly Please help me out. - 
Create a class that has a method accepting two strings. The method searches for contacts that have a last name matching the first string and a mailing postal code (API name: MailingPostalCode) matching the second. It gets the ID and Name of those contacts and returns them.The Apex class must be called 'ContactSearch' and be in the public scope.
The Apex class must have a public static method called 'searchForContacts'.
The 'searchForContacts' method must accept two incoming strings as parameters, find any contact that has a last name matching the first, and mailing postal code matching the second string. The method should return a list of Contact records with at least the ID and Name fields.
The return type for 'searchForContacts' must be 'List<Contact>'.