• Ronan O'Neill 6
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 11
    Replies
I have a SelectList which is dynamically built from the controller. But it doesn't seem to get run in the Test Class. How can I make sure its covered?
 
public List<SelectOption> getCountyList() {
        List<SelectOption> options = new List<SelectOption>();
        
        String counties = contactInfo[0].Preferred_Counties_for_Volunteering__c;
        
        if(!counties.contains(contactInfo[0].Home_County__c)) {
            
            options.add(new SelectOption(contactInfo[0].Home_County__c, contactInfo[0].Home_County__c));
        }
        
        List<String> prefCounties = counties.split(';', -2);
  		
        for(String pref : prefCounties) {
            
            options.add(new SelectOption(pref,pref));
    
        }
        
        return options;
    }

My Test Class currently
 
@isTest
public class ToTestFindNearby {

    static testMethod void testFindNearby () {
        
        PageReference pageRef = Page.FindNearby; 
        
        Contact contact = new Contact (LastName = 'Test', Are_you_an_Engineer__c = 'Engineer', Home_County__c = 'Waterford' );
        Account school = new Account (Name = 'Test', County__c = 'Waterford', Lat__c=5.0000, Lng__c=10.000, isMapped__c = true);
 		//Test.startTest();
        insert contact;
        insert school; 
        
        system.assertEquals(true, school.isMapped__c);
        
        date myDate = date.newInstance(2015, 11, 21);

        
        School_Visit__c schoolVisit = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = 'Science', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon', Date__c= myDate);
        
        School_Visit__c schoolVisit2 = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = 'Engineering', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon');
        
        School_Visit__c schoolVisit3 = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = '', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon');
        insert schoolVisit;
        insert schoolVisit2;
        insert schoolVisit3;
        //Test.stopTest();
       
        pageRef.getParameters().put('id', contact.id);
        Test.setCurrentPage(pageRef);
		FindNearby controller = new FindNearby();
        controller.backToContact();
        
    }
}

 
Hi, 

I created a List<Account> which takes the result of a database query. Later in the code I want to update two of the values in this List with new values. The values should be of type Double, but I seem to be only allowed add them to the List if I cast them as type Account. 

Unfortunately I then get an error "Invalid conversion from runtime type Decimal to Account".
Class variable
public static List<Account> contactLatLng {get;set;};

In Constructor
contactLatLng = Database.query(queryContact);

In Class Method
if(status =='OK') {
            List<Object> results = (List<Object>) ((Map<String, Object>)JSON.deserializeUntyped(response)).get('results');
            Map<String, Object> geometry = (Map<String, Object>) ((Map<String, Object>) results.get(0)).get('geometry');
            Map<String, Object> location = (Map<String, Object>) geometry.get('location');
            Account lat = (Account)(location.get('lat'));
            Account lng = (Account)location.get('lng');
            
            contactLatLng.set(0, lat);
            contactLatLng.set(1, lng);

So whats the best way to have the values from the database query updateable. Could I swap them to a List of a different type to make it easier?

Thanks,
 
Hey, I have a selectList on a page which ties to a String value. I want the value to be updated, the page to reload using this value for a calculation and the selectList to display this value as the current one. I'd like it to happen on change of the value unless a button is required. Any help would be appreciated.
I had tried some javascript to reload the page thinking the value would be automically passed but not finding that to be the case.

My selectList

<apex:selectList value="{!dist}" onchange="document.location.reload(true);" size="1">
          <apex:selectOptions value="{!distList}" ></apex:selectOptions>
      </apex:selectList>

My Controller

public static String dist {get;set;}
    
    public static List<SelectOption> getdistList() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('25','25km'));
        options.add(new SelectOption('50','50km'));
        options.add(new SelectOption('100','100km'));
        return options;
    }

So first off I noticed there are built in Lattitute and Longitude fields for Account objects. Do these already get updated when address is filled in? Executing in Query Editor does not seem to give me a value in the Developers Console.

Either way I started building a Geocoding class via google maps and I wanted it to automatically fire when the address of an Account is inserted or updated. 

My Trigger was initially After Update, Insert but I got an error for read only values. I then tried Before Update, Insert which seemed anti intutive but I now get a null value for the ID I think.

My code is below but I essentially just want a way to fire a trigger to update a field in Accounts when the address field in Account is updated or created?

trigger AddLocation on Account (before insert, before update) {
    
    for (Account updatedAccount : Trigger.new) {
       
      // if( (Trigger.oldMap.get(updatedAccount.Id).BillingStreet != 
         // Trigger.newMap.get(updatedAccount.Id).BillingStreet)||( Trigger.oldMap.get(updatedAccount.Id).BillingCity != 
         // Trigger.newMap.get(updatedAccount.Id).BillingCity)||( Trigger.oldMap.get(updatedAccount.Id).BillingState != 
        // Trigger.newMap.get(updatedAccount.Id).BillingState)||( Trigger.oldMap.get(updatedAccount.Id).BillingPostalCode != 
        //  Trigger.newMap.get(updatedAccount.Id).BillingPostalCode)){
              
        Geocoding updater = new Geocoding(updatedAccount.Id);
        
        updatedAccount.BillingLatitude = updater.getLat();
        updatedAccount.BillingLongitude = updater.getLng();
        
            //}
   }     

I was trying to build a URL using the address saved as a field in the database. 

I'm having trouble figuring out how to get the result of a database query as a string so as to edit and append it tio URL. 

Is there an easy way to do that?

Thanks.
Hi, 

I was experimenting with single sign on and I think I managed to create a scenario where by I can't log in via salesforce log in page and my own domains log in page is stuck in an authentication loop which means I can never log in again. 

The specific settings at fault are under My Domain, 
Prevent login from https://login.salesforce.com and
Authentication Service changed from Log in

My user name is ronan@ecass.com 

I sent a support case in via our main salesforce but they suggested I ask someone here. If there are salesforce people who can access my account and reset the log in settings that would be great. Or if someone knows how to fix this without being able to log in. 

Thanks, 
 
I have a SelectList which is dynamically built from the controller. But it doesn't seem to get run in the Test Class. How can I make sure its covered?
 
public List<SelectOption> getCountyList() {
        List<SelectOption> options = new List<SelectOption>();
        
        String counties = contactInfo[0].Preferred_Counties_for_Volunteering__c;
        
        if(!counties.contains(contactInfo[0].Home_County__c)) {
            
            options.add(new SelectOption(contactInfo[0].Home_County__c, contactInfo[0].Home_County__c));
        }
        
        List<String> prefCounties = counties.split(';', -2);
  		
        for(String pref : prefCounties) {
            
            options.add(new SelectOption(pref,pref));
    
        }
        
        return options;
    }

My Test Class currently
 
@isTest
public class ToTestFindNearby {

    static testMethod void testFindNearby () {
        
        PageReference pageRef = Page.FindNearby; 
        
        Contact contact = new Contact (LastName = 'Test', Are_you_an_Engineer__c = 'Engineer', Home_County__c = 'Waterford' );
        Account school = new Account (Name = 'Test', County__c = 'Waterford', Lat__c=5.0000, Lng__c=10.000, isMapped__c = true);
 		//Test.startTest();
        insert contact;
        insert school; 
        
        system.assertEquals(true, school.isMapped__c);
        
        date myDate = date.newInstance(2015, 11, 21);

        
        School_Visit__c schoolVisit = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = 'Science', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon', Date__c= myDate);
        
        School_Visit__c schoolVisit2 = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = 'Engineering', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon');
        
        School_Visit__c schoolVisit3 = new School_Visit__c (School__c = school.id, Status__c = 'Open for Volunteering', 
                                      Topic__c = '', How_many_students_in_the_class__c = 15, Requires_Irish_speaker__c = 'No',
                                      Preferred_Time__c = 'Afternoon');
        insert schoolVisit;
        insert schoolVisit2;
        insert schoolVisit3;
        //Test.stopTest();
       
        pageRef.getParameters().put('id', contact.id);
        Test.setCurrentPage(pageRef);
		FindNearby controller = new FindNearby();
        controller.backToContact();
        
    }
}

 
Hi, 

I created a List<Account> which takes the result of a database query. Later in the code I want to update two of the values in this List with new values. The values should be of type Double, but I seem to be only allowed add them to the List if I cast them as type Account. 

Unfortunately I then get an error "Invalid conversion from runtime type Decimal to Account".
Class variable
public static List<Account> contactLatLng {get;set;};

In Constructor
contactLatLng = Database.query(queryContact);

In Class Method
if(status =='OK') {
            List<Object> results = (List<Object>) ((Map<String, Object>)JSON.deserializeUntyped(response)).get('results');
            Map<String, Object> geometry = (Map<String, Object>) ((Map<String, Object>) results.get(0)).get('geometry');
            Map<String, Object> location = (Map<String, Object>) geometry.get('location');
            Account lat = (Account)(location.get('lat'));
            Account lng = (Account)location.get('lng');
            
            contactLatLng.set(0, lat);
            contactLatLng.set(1, lng);

So whats the best way to have the values from the database query updateable. Could I swap them to a List of a different type to make it easier?

Thanks,
 

Hi All,

in my VF page i've got a table. I would like to show only certain values and, since it is a VF, i can set rendered.
My problem is that, using rendered, the VF correctly hide the record but also leave the corresponding row empy. Looking at the picture, I would like that the first 3 rows disappear.
 

User-added image 

Thankyou!

 

Hey, I have a selectList on a page which ties to a String value. I want the value to be updated, the page to reload using this value for a calculation and the selectList to display this value as the current one. I'd like it to happen on change of the value unless a button is required. Any help would be appreciated.
I had tried some javascript to reload the page thinking the value would be automically passed but not finding that to be the case.

My selectList

<apex:selectList value="{!dist}" onchange="document.location.reload(true);" size="1">
          <apex:selectOptions value="{!distList}" ></apex:selectOptions>
      </apex:selectList>

My Controller

public static String dist {get;set;}
    
    public static List<SelectOption> getdistList() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('25','25km'));
        options.add(new SelectOption('50','50km'));
        options.add(new SelectOption('100','100km'));
        return options;
    }

So first off I noticed there are built in Lattitute and Longitude fields for Account objects. Do these already get updated when address is filled in? Executing in Query Editor does not seem to give me a value in the Developers Console.

Either way I started building a Geocoding class via google maps and I wanted it to automatically fire when the address of an Account is inserted or updated. 

My Trigger was initially After Update, Insert but I got an error for read only values. I then tried Before Update, Insert which seemed anti intutive but I now get a null value for the ID I think.

My code is below but I essentially just want a way to fire a trigger to update a field in Accounts when the address field in Account is updated or created?

trigger AddLocation on Account (before insert, before update) {
    
    for (Account updatedAccount : Trigger.new) {
       
      // if( (Trigger.oldMap.get(updatedAccount.Id).BillingStreet != 
         // Trigger.newMap.get(updatedAccount.Id).BillingStreet)||( Trigger.oldMap.get(updatedAccount.Id).BillingCity != 
         // Trigger.newMap.get(updatedAccount.Id).BillingCity)||( Trigger.oldMap.get(updatedAccount.Id).BillingState != 
        // Trigger.newMap.get(updatedAccount.Id).BillingState)||( Trigger.oldMap.get(updatedAccount.Id).BillingPostalCode != 
        //  Trigger.newMap.get(updatedAccount.Id).BillingPostalCode)){
              
        Geocoding updater = new Geocoding(updatedAccount.Id);
        
        updatedAccount.BillingLatitude = updater.getLat();
        updatedAccount.BillingLongitude = updater.getLng();
        
            //}
   }     

Hi Everyone,

I am generating a pdf in which I have put footers on each page but i don't want to show the footer at the last page of the pdf.

We have @page :first which works for the first page but we don't have @page :last in css.

Is there anyway to solve this problem?


Thanks in Advance
I am facing an issue while configuring SSO. I have 2 free Developer Edition orgs.  One is set up as the Identity Provider using Salesforce's built-in IDP service.  I set up the othe org as a Service Provider. In the IDP org, I added the Service Provider as a connected app as defined under "Setup" > "Security Controls" > "Identity Provider".  I also assigned a profile to the connected app. I should end up with a new Service Provider listed under Identity Provider. However, when I go to the Identity Provide page under "Setup" > "Security Controls" > "Identity Provider", the list of Service Providers is empty . What could be the possible reason? Am I missing any other step? Below is a link to the workbook exercise I am following:

https://developer.salesforce.com/page/Implementing_Single_Sign-On_Across_Multiple_Organizations

Thank you for your help!