• Robert Robinson
  • NEWBIE
  • 139 Points
  • Member since 2015
  • Manager, Salesforce Application
  • Welltower


  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 62
    Replies
I have two Objects (Deal__c and Property__c) that I would like to join in a related list. Deal and Property are not related to each other but they do have a junction object Deal_Property__c (Deal is the master of Deal Property, and Deal Property has Property as a lookup field). I want to create a controller extension that for Deal A lists Properties 1, 2 and 3. I think this is possible but I cannot come up with the correct syntax. I've searched the documentation and Trailhead, but cannot quite find what I am looking for. Any ideas? Thanks.
I am creating a test class for an Apex class. My code:

@isTest
public class LsUnitListTest
{
    static testMethod void testLsUnitListPage()
    {
    
        Lease__c objLease = new Lease__c(Name = 'Test Lease');
        insert objLease;
       
        List<Lease_Unit_Association__c> lstUnit = new List<Lease_Unit_Association__c>{  new Unit__c(    Unit__c = 'Test Unit1', Unit__c = objLease.ID,  Property_Unit__r.Unit_Status_Code__c = 'N'),


I am encountering the following error:
Error: Compile Error: Invalid field Unit__c for SObject Unit__c at line 10 column 115

I am not quite sure what it is telling me. Do I have an invalid field type in the test? I get the feeling it is something obvious. Any help would be appreciated. Thanks.
I am using an apex:Pageblock with a 6 column panelgrid to create pagination for a custom related list. I have everything working ok except for 1 piece. I created a "Go to List" function that pulls up the list of related records. So that this will appear, I am using the apes:commandLink value function as follows:
  <apex:commandLink value="Go to List" rendered="{!units.hasNext}" action="{!showAll}"/>
This block gives users these options: Go to List  Next  Last on page 1, Go to List First Previous Next Last on page 2 and so on. On the last page, the user sees First  Previous as options 
I think this is where i painted myself into a corner; the Go to List option appears only as long as there is a "Next" option; on the last page (no next), Go to List is not an option.

Here is the pertinent block of code:
 </apex:pageBlockButtons> 
      <apex:panelGrid columns="6" id="linkPanel">
        <apex:commandLink value="Go to List" rendered="{!units.hasNext}" action="{!showAll}"/>       
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!first}" value="First" rendered="{!units.hasPrevious}"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!previous}" rendered="{!units.hasPrevious}" value="Previous"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!next}" rendered="{!units.hasNext}" value="Next"/>
        <apex:commandLink status="fetchStatus" reRender="pblock" action="{!last}" rendered="{!units.hasNext}" value="Last"/>
        <apex:outputText id="pNum">{!IF(noofrecords=0,'No records to display',TEXT((units.pageNumber * size)+1-size)+'-'+IF((units.pageNumber * size)>noOfRecords, TEXT(noOfRecords),TEXT((units.pageNumber * size)))+' of '+ TEXT(noofrecords))}</apex:outputText>
        <apex:outputPanel style="color:#4AA02C;font-weight:bold">
        <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
        </apex:outputPanel>
      </apex:PanelGrid>
    </apex:pageBlock>

Is there another function that I can use to ensure that the Go to Link option appears on the last page of the list? Thanks.
This is a strange one. I cannot log into developer.salesforce.com on my PC. I am sending this from my iPad. Has anyone else experienced this?
I am running a SOQL query. In it, I want to display the name of the Record Type rather than the ID number. If I create a query that includes:
Select .... RecordTypeID, I get the record type ID; however, when I use "RecordTypeID.name" or "RecordTypeID__r.name", I get this error:

ERROR at Row:1:Column:121
Didn't understand relationship 'RecordTypeID__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.


I have the feeling that the Record Type name has different properties, but I am not using the correct syntax to display the name. What am I missing. Thanks. 
General question: Standard Salesforce pages provide the ability to resequence a form's contents when a header is clicked (once for ascending, a second time for descending). when buildin a Visualforce page, what is the code used to provide that resequencing functionality? I would think it would be an addition to the columnHeader value portion of the apex code, but I can not find the specific coding. Something that would fit inside:
<apex:column headerValue="Property Name">
      <apex:outputLink value="/{!mp['Id']}" title="{!mp['Name']}" target="_top">{!mp['Name']}
      </apex:outputLink>
</apex:column>

Any ideas?
I want to change colors for the markers on a Google map. I saw the Summer '15 release notes ("Customize Visualforce Maps with Custom Markers") so I gave it a shot. I created a custom marker, saved it as a jpg, then saved the jpg as a static resource. I then added the follofing line to my Visualforce page:
...icon="{! URLFOR($Resource.HCNMarker, 'marker.jpg') }" />
The VF page saved, but when I pulled up a sample, the markers do not appear on the map. I went back and mispelled the name of the static resource and tried to save. I then received an error on the VF page, which tells me that the code is seeing the static resource; i am just not seeing the markers. Is there anything else I am missing?
I am creating a map that pinpoints multiple locations (multiple locations in a MSA). The map involves two custom objects: Markets (MSA) and Properties. I have created the Visualforce Page and a related extension (both included below). The output should be split into two sections: the first (left) will be a list of the properties in the MSA, and the second block (right) will be the map itself. The VF Page and the extension compile without issue. When I run the page for an MSA value, the list appears on the left; however, the map does not appear. I must be missing something.

Visualforce Page
<apex:page sidebar="false" showHeader="false" standardController="Market__c" extensions="MSAProperty" >
  <!-- This page must be accessed with an Market Id in the URL. For example: 
       https://cs41.salesforce.com/apex/rrmultipropmap?id=a1255000002hr4G -->
  <apex:pageBlock >
    <apex:pageBlockSection Title="Properties in {!Market__c.Name} MSA"> 
      <apex:pageBlockTable value="{!mprops}" var="mp">
       <apex:column value="{!mp['Name']}"/>
       <apex:column value="{!mp['Address__c']}"/>
       <apex:column value="{!mp['City__c']}"/>
       <apex:column value="{!mp['State__c']}"/>
       <apex:column value="{!mp['Zip__c']}"/>
   <apex:map width="600px" height="400px" mapType="roadmap"
    center="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}">
     <apex:repeat value="{!mprops}" var="mp">
       <apex:mapMarker title="{! mp.Name }"
      position="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}"/>
     </apex:repeat>
   </apex:map>
     </apex:pageBlockTable>
    </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

Apex Controller Extension
/*Controller class for the Multimktmap visualforce page used inline on Market layouts
to show only active Units related to the Property
*/
public class MSAProperty{
    public MSAProperty() {
    }
   public List<Property__c> mprops {get;set;}
   public MSAProperty(ApexPages.StandardController cont) {
      String ID = cont.getId();
      mprops = [Select Name, Address__c, City__c, State__c, Zip__c 
                  from Property__c 
                  where Market__c = :cont.getId()];
              }
        }
 
I have a custom field (Tenant__c) which represents a lookup value for Accounts. I am trying to write a SOQL query to extract the names in this field, rather than the 18 character case safe value. I know when you are trying to to pull the name for the Account field, you express it as "Account.Name", but I cannot get the correct syntax for this custom field (Tenant.Name__c does not work). What is the correct syntax in this situation? Thank you.
I am trying to create a test class for a controller extenstion that performs a SOQL query and sets up the VF page for pagination. Most test class examples that I have found have been for insertion of records, not data selection and listing. Can someone provide suggestions on the controller extension shown below? Thanks. 

public class DealList{    
 public Integer noOfRecords{get; set;}    
 public Integer size{get;set;}     
 public boolean showHeaderSideBar{get;set;}     
 public String redirectUrl {get;set;}     
ApexPages.StandardController controller;    
private boolean fullscreen;    
public DealList(ApexPages.StandardController controller) {        
this.controller = controller;       
 //check if page needs to be opened in full screen mode        
String value = ApexPages.currentPage().getParameters().get('fullscreen');        
if(String.isNotBlank(value) && value == 'true'){            
fullscreen = true;            
showHeaderSideBar = true;        }else{             
fullscreen = false;             
showHeaderSideBar = false;           
   }    
}     
public ApexPages.StandardSetController deals{          
get{             
if(deals == null){                 
if(fullscreen) size = 100;                 
if(size==null) size=5;                 
deals = new ApexPages.StandardSetController(Database.getQueryLocator( [Select Name, Location__c, Asset_Type__c, Underwriter__c, Amount__c, Stage__c, Estimated_Close__c, Closing_Probability_Category__c                    
    from Deal__c                     
     where Account_Name__c = :controller.getId()                    
       and Status__c = 'Open']));                 
      deals.setPageSize(size);                 
       noOfRecords = deals.getResultSize();             
}             
return deals;         
}         
set;     
}     
public Boolean hasNext {         
get {             
return deals.getHasNext();         
}         
set;     
}     
public Boolean hasPrevious {         
get {             
return deals.getHasPrevious();        
 }         
set;     
}     
public Integer pageNumber {         
get {             
return deals.getPageNumber();        
 }         
set;     
}     
public void first() {
        deals.first();     
}     
public void last() {         
deals.last();     
}     
public void previous() {         
deals.previous();    
 }     
public void next() {         
deals.next();    
 }     
public PageReference refreshPageSize() {          
deals.setPageSize(size);          
return null;     
}     
public void showAll(){         
redirectUrl = '/apex/AcctDealRelatedList?id='+controller.getId()+'&fullscreen=true';     
}     
public void saveDeals(){         
try {             
deals.save();         

catch (Exception e) {             
ApexPages.addMessages(e);         
}     
}
}
We have created an Object called "Markets" following the standard MSA codes. Within each market, we have several accounts. I have had success mapping single accounts using a Visual Force page, but now I am looking to map multiple accounts within an MSA zone. Has anyone come up with a way to map multiple points in Visual Force? I am trying to avoid pay apps like Geopointe or MapAnything. Thanks.