• Christopher_Alun_Lewis
  • NEWBIE
  • 75 Points
  • Member since 2010
  • Senior Applications Developer
  • Cloud Clew


Badges

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

I have been having some serious issues getting maps to work like they should in VF pages, but it seems that the functions we have to check if it has null or blank values don't really work for maps. Here is a simple example of what I am trying to do:

<apex:page showHeader="true" sidebar="true" controller="sfg_ContactPhotos">
  <apex:repeat value="{!lstOfContacts}" var="c">

    <apex:image rendered="{!ISBLANK(mapOfPhotos[c.Id])}" url="{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}" width="50" height="50" />

  </apex:repeat>
</apex:page>

 Even it it wasn't an Attachment, it could be anything, the point is that the ISBLANK should see if the map has a value and if not, don't show it, instead it causes an error on the page:


Map key 003J000000T3woPIAR not found in map

Error is in expression '{!ISBLANK(mapOfPhotos[c.Id])}' in component <apex:image> in page sfg_contactphoto
 
I added a debug and the Map key is there, even though the error complains about it not being there.
 
USER_DEBUG|[42]|DEBUG|{003G0000010ItFZIA0=null, 003G0000010JMiwIAG=null, 003J000000Q0n7FIAR=null, 003J000000Q0nBGIAZ=null, 003J000000Q1E9XIAV=null, 003J000000Q1EAyIAN=null, 003J000000SfAzLIAV=00PJ0000000fM1YMAU, 003J000000Shhd2IAB=null, 003J000000T3wmxIAB=00PJ0000000fsDfMAI, 003J000000T3woPIAR=null, ...}
 
At the very least the error should say something like:
 
Map value not found in Map 
 
Regardless, is there a VF function to check maps? I am trying to give sfdc the benefit of the doubt that I am just using the wrong function, but when looking at the documentation there seems to be nothing. I even tried NULLVALUE even though its not exactly what I need since it has an alternate value instead of boolean likst ISBLANK and so can't really be used in the rendered attribute. I even tried changing it so that it wasnt an Object or Id, and to a String, but then the Attachment complains that its not the correct type of value:
 
Invalid parameter for function URLFOR
Error is in expression '{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}' in component <apex:page> in page sfg_contactphoto

I also tried conveting the Id to a string for just the check since it seemed to work above:
 
<apex:image rendered="{!NOT(ISBLANK(TEXT(mapOfPhotos[c.Id])))}" url="{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}" width="50" height="50" />

 but it just give the same error as the first time:

 

Map key 003J000000T3woPIAR not found in map

Error is in expression '{!ISBLANK(mapOfPhotos[c.Id])}' in component <apex:image> in page sfg_contactphoto

I can get what I need do using an alternative way, but it should work with maps. 
 
here is the controller if anyone is interested:
public class sfg_ContactPhotos {

  public List<Contact> lstOfContacts {get; set;}
  public Map<Id, Id> mapOfPhotos {get; set;}

  public sfg_ContactPhotos() {
    lstOfContacts = findContacts();
    mapOfPhotos = buildPhotoMap(lstOfContacts);
  }

  private List<Contact> findContacts() {
    return [select Name, 
                   Email,
                   (select ContentType
                    from Attachments
                    where isPrivate = false
                    order by LastModifiedDate desc)
            from Contact
            order by LastModifiedDate desc
            limit 10];
  }

  private Map<Id, Id> buildPhotoMap(List<Contact> pContacts) {
    if (pContacts.isEmpty()) {
      return new Map<Id, Id>();
    }

    Map<Id, Id> returnMap = new Map<Id, Id>();
    for (Contact c : pContacts) {
      for (Attachment a : c.Attachments) {
        if (returnMap.containsKey(c.Id)) {
          break;
        }
        if (a.ContentType.contains('image/')) {
          returnMap.put(c.Id, a.Id);
          break;
        }
      }
      if (!returnMap.containsKey(c.Id)) {
        returnMap.put(c.Id, null);
      }
    }
    return returnMap;
  }

}

 


Hello. When I execute Url. getSalesforceBaseUrl().toExternalForm() in the system console, the returned URL uses https:// However, when I execute this in the finish() method of Batch Apex, it returns http:// 

Is this a bug? I need https:// returned in the Batch Apex. 

Thanks 
David
 

Building on the highly successful "Force West" Salesforce networking community for the South West, a developer spin off community, "Force by Force West" (FxFW) is starting.

The aim of this new group is to share experiences and thoughts on all things Force.com over a pint or two, from Apex and Visualforce to mobile applications and alternative cloud platforms.

The first event will take place on the 31st May at the Elephant pub in Central Bristol, next to St. Nicholas Market. 

 

More information about the event and group can be found through the FxFW Facebook Page, or by following the FxFW Barman on Twitter.

If you are interested, let us know by registering on our Eventbrite entry, purely so we can get an idea of how many are coming down.

 

Thanks,

 

Christopher Alun Lewis

 

-----------------------------------------------------------------------------------------------------

 

Check out my blog for all things Visualforce & Apex --> http://christopheralunlewis.blogspot.co.uk/

Hello all,

 

Recently I have been building a new Salesforce custom application that contains two custom objects. The purpose of these custom objects is to store questions that we pose to our contacts (Question__c), and also the answers that they provide (Answer__c). The answer object is a junction object that has master detail relationships with both the custom question object and the standard contact object.

 

This works well for us as a data model. We can interact with the data effectively through the standard salesforce GUI and reports. However, we are finding that our storage space is being filled up rapidly. Each answer a customer gives takes 2KB worth of storage, which seems a lot considering a large proportion of the questions require simple "Yes" or "No" answers.

 

Can anybody suggest a better way to model the data so that storage is not exceeded so quickly, while maintaining the usability of the data within the standard Salesforce GUI. 

 

Before custom fields on the contact object are suggested, we intend to store over 500 questions eventually, which would exceed the maximum amount of custom fields permitted on an object.

 

November 24, Bristol: A NEW free networking group for Salesforce.com professionals in the South West

 

Desynit are setting up a networking group for Salesforce.com professionals in the South West. Whether you are a developer or a user, if your work life brings you into contact with the Salesforce.com platform, come to our first free event in Bristol on the 24th November 2011, 6pm. Visit our Eventbrite page to register.

Hello Everyone,

 

I'm having a real hard time styling an apex:pageBlockTable. I have a series of four columns containing fields from a custom object, and then another field containing a long description that I position underneath the previous fields using breakbefore="true" . I am spreading this field to the whole length of the row using colspan="4". The problem is that the lines betweens the columns and rows are behaving strangely and I can find no way of altering them. My ideal result would be for the rows to be clearly identifiable as "belonging to each other", placing borders between "pairs" of rows for example.

 

To illustrate the problem, I have built up a similar example using the contact object instead of my custom object. 

 

Page Code

 

<apex:page controller="StylePageBlockTableController">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!allContacts}" var="contact">
            <apex:column value="{!contact.Name}" headervalue="Full Name"/>
            <apex:column value="{!contact.Title}" headervalue="Title"/>
            <apex:column value="{!contact.Department}" headervalue="Department"/>
            <apex:column value="{!contact.Phone}" headervalue="Phone"/>
            <apex:column value="{!contact.Email}" breakBefore="true" colspan="4"/>
        </apex:pageBlockTable>
    </apex:pageBlock>         
</apex:page>
<apex:page controller="StylePageBlockTableController">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!allContacts}" var="contact">
            <apex:column value="{!contact.Name}" headervalue="Full Name"/>
            <apex:column value="{!contact.Title}" headervalue="Title"/>
            <apex:column value="{!contact.Department}" headervalue="Department"/>
            <apex:column value="{!contact.Phone}" headervalue="Phone"/>
            <apex:column value="{!contact.Email}" breakBefore="true" colspan="4"/>
        </apex:pageBlockTable>
    </apex:pageBlock>         
</apex:page>

 

Controller Code

 

public class StylePageBlockTableController {
    
    public List<Contact> getAllContacts(){
        return [select Name, Title, Department, Email, Phone from Contact limit 5 ];
    }
}

 

Here is a screenshot of the table, as I have highlighted, there is a random "missing border line" that always appears (or rather doesn't) at exactly half way down the table. No matter what the size of the table, this missing line is always in the middle.

 

Problems displaying pageBlockTable

 

I have tried using style classes and the rules attribute (which seems utterly redundant and does not seem to affect anything, perhaps the new SF styling??)  amongst others. Any ideas anyone, greatly appreciated! 

I'm working through Apex & .NET Basics - Understanding Execution Context

When validating the challenge I'm getting the error:
 
Challenge Not yet complete... here's what's wrong: 
The Trigger 'AccountTrigger' does not appear to be calling the AccountTriggerHandler class correctly or using isBefore or isInsert content variables.

The trigger I currently have is minimal:

trigger AccountTrigger on Account (before insert) {
    AccountTriggerHandler.CreateAccounts(Trigger.new);
}

Why would I need to check Trigger.isBefore and Trigger.isInsert if the trigger is only on before insert?

 
I have made all the changes as per the task requirements but getting this errror. Please help me.

I have been having some serious issues getting maps to work like they should in VF pages, but it seems that the functions we have to check if it has null or blank values don't really work for maps. Here is a simple example of what I am trying to do:

<apex:page showHeader="true" sidebar="true" controller="sfg_ContactPhotos">
  <apex:repeat value="{!lstOfContacts}" var="c">

    <apex:image rendered="{!ISBLANK(mapOfPhotos[c.Id])}" url="{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}" width="50" height="50" />

  </apex:repeat>
</apex:page>

 Even it it wasn't an Attachment, it could be anything, the point is that the ISBLANK should see if the map has a value and if not, don't show it, instead it causes an error on the page:


Map key 003J000000T3woPIAR not found in map

Error is in expression '{!ISBLANK(mapOfPhotos[c.Id])}' in component <apex:image> in page sfg_contactphoto
 
I added a debug and the Map key is there, even though the error complains about it not being there.
 
USER_DEBUG|[42]|DEBUG|{003G0000010ItFZIA0=null, 003G0000010JMiwIAG=null, 003J000000Q0n7FIAR=null, 003J000000Q0nBGIAZ=null, 003J000000Q1E9XIAV=null, 003J000000Q1EAyIAN=null, 003J000000SfAzLIAV=00PJ0000000fM1YMAU, 003J000000Shhd2IAB=null, 003J000000T3wmxIAB=00PJ0000000fsDfMAI, 003J000000T3woPIAR=null, ...}
 
At the very least the error should say something like:
 
Map value not found in Map 
 
Regardless, is there a VF function to check maps? I am trying to give sfdc the benefit of the doubt that I am just using the wrong function, but when looking at the documentation there seems to be nothing. I even tried NULLVALUE even though its not exactly what I need since it has an alternate value instead of boolean likst ISBLANK and so can't really be used in the rendered attribute. I even tried changing it so that it wasnt an Object or Id, and to a String, but then the Attachment complains that its not the correct type of value:
 
Invalid parameter for function URLFOR
Error is in expression '{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}' in component <apex:page> in page sfg_contactphoto

I also tried conveting the Id to a string for just the check since it seemed to work above:
 
<apex:image rendered="{!NOT(ISBLANK(TEXT(mapOfPhotos[c.Id])))}" url="{!URLFOR($Action.Attachment.Download, mapOfPhotos[c.Id])}" width="50" height="50" />

 but it just give the same error as the first time:

 

Map key 003J000000T3woPIAR not found in map

Error is in expression '{!ISBLANK(mapOfPhotos[c.Id])}' in component <apex:image> in page sfg_contactphoto

I can get what I need do using an alternative way, but it should work with maps. 
 
here is the controller if anyone is interested:
public class sfg_ContactPhotos {

  public List<Contact> lstOfContacts {get; set;}
  public Map<Id, Id> mapOfPhotos {get; set;}

  public sfg_ContactPhotos() {
    lstOfContacts = findContacts();
    mapOfPhotos = buildPhotoMap(lstOfContacts);
  }

  private List<Contact> findContacts() {
    return [select Name, 
                   Email,
                   (select ContentType
                    from Attachments
                    where isPrivate = false
                    order by LastModifiedDate desc)
            from Contact
            order by LastModifiedDate desc
            limit 10];
  }

  private Map<Id, Id> buildPhotoMap(List<Contact> pContacts) {
    if (pContacts.isEmpty()) {
      return new Map<Id, Id>();
    }

    Map<Id, Id> returnMap = new Map<Id, Id>();
    for (Contact c : pContacts) {
      for (Attachment a : c.Attachments) {
        if (returnMap.containsKey(c.Id)) {
          break;
        }
        if (a.ContentType.contains('image/')) {
          returnMap.put(c.Id, a.Id);
          break;
        }
      }
      if (!returnMap.containsKey(c.Id)) {
        returnMap.put(c.Id, null);
      }
    }
    return returnMap;
  }

}

 


Hello all,

 

Recently I have been building a new Salesforce custom application that contains two custom objects. The purpose of these custom objects is to store questions that we pose to our contacts (Question__c), and also the answers that they provide (Answer__c). The answer object is a junction object that has master detail relationships with both the custom question object and the standard contact object.

 

This works well for us as a data model. We can interact with the data effectively through the standard salesforce GUI and reports. However, we are finding that our storage space is being filled up rapidly. Each answer a customer gives takes 2KB worth of storage, which seems a lot considering a large proportion of the questions require simple "Yes" or "No" answers.

 

Can anybody suggest a better way to model the data so that storage is not exceeded so quickly, while maintaining the usability of the data within the standard Salesforce GUI. 

 

Before custom fields on the contact object are suggested, we intend to store over 500 questions eventually, which would exceed the maximum amount of custom fields permitted on an object.

Hello. When I execute Url. getSalesforceBaseUrl().toExternalForm() in the system console, the returned URL uses https:// However, when I execute this in the finish() method of Batch Apex, it returns http:// 

Is this a bug? I need https:// returned in the Batch Apex. 

Thanks 
David
 

Hi,

 

I have two questions related with Approvals.

 

1. Is their a way to make Approver comments required while approving or rejecting any record?

2.  How can we make any field required on record while some one is approving or rejecting the record?

 

 

Cheers!

Rajan

Hello Everyone,

 

I'm having a real hard time styling an apex:pageBlockTable. I have a series of four columns containing fields from a custom object, and then another field containing a long description that I position underneath the previous fields using breakbefore="true" . I am spreading this field to the whole length of the row using colspan="4". The problem is that the lines betweens the columns and rows are behaving strangely and I can find no way of altering them. My ideal result would be for the rows to be clearly identifiable as "belonging to each other", placing borders between "pairs" of rows for example.

 

To illustrate the problem, I have built up a similar example using the contact object instead of my custom object. 

 

Page Code

 

<apex:page controller="StylePageBlockTableController">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!allContacts}" var="contact">
            <apex:column value="{!contact.Name}" headervalue="Full Name"/>
            <apex:column value="{!contact.Title}" headervalue="Title"/>
            <apex:column value="{!contact.Department}" headervalue="Department"/>
            <apex:column value="{!contact.Phone}" headervalue="Phone"/>
            <apex:column value="{!contact.Email}" breakBefore="true" colspan="4"/>
        </apex:pageBlockTable>
    </apex:pageBlock>         
</apex:page>
<apex:page controller="StylePageBlockTableController">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!allContacts}" var="contact">
            <apex:column value="{!contact.Name}" headervalue="Full Name"/>
            <apex:column value="{!contact.Title}" headervalue="Title"/>
            <apex:column value="{!contact.Department}" headervalue="Department"/>
            <apex:column value="{!contact.Phone}" headervalue="Phone"/>
            <apex:column value="{!contact.Email}" breakBefore="true" colspan="4"/>
        </apex:pageBlockTable>
    </apex:pageBlock>         
</apex:page>

 

Controller Code

 

public class StylePageBlockTableController {
    
    public List<Contact> getAllContacts(){
        return [select Name, Title, Department, Email, Phone from Contact limit 5 ];
    }
}

 

Here is a screenshot of the table, as I have highlighted, there is a random "missing border line" that always appears (or rather doesn't) at exactly half way down the table. No matter what the size of the table, this missing line is always in the middle.

 

Problems displaying pageBlockTable

 

I have tried using style classes and the rules attribute (which seems utterly redundant and does not seem to affect anything, perhaps the new SF styling??)  amongst others. Any ideas anyone, greatly appreciated! 

Updated 10/27/2011

Due to too many mis-posted threads here, I'm going to ask for bona-fide announcments that you precede your title with a categorization: "Webinar:", "Product Release: ", "Networking: " or "Event: ". E.g., "Webinar: Build data-rich websites with Siteforce".

 

If you have another category of announcement that should be included email me and let me know (dle@salesforce.com). I'm trying to cut down on the misposts to Announcements. 

 

IF YOU POST WITHOUT AN ANNOUNCEMENT CATEGORY I WILL DELETE YOUR POSTING. Moderators are spending too much time moving threads around.

 

Thanks!

 

Hey community pals,

 

We conferred about this and decided to open up the Announcements board to the entire community. To be clear, please only post your announcements that would be of interest to the Developer Force community, such as developer-focused events and product launches.

 

Please don't abuse the privilege and only post items of interest. Thank you!

 

 

With the Summer'10 release, the Report Builder also is able to edit Summary Reports. During June, we added Boolean filtering and conditional highlighting. As of June 28th, this excludes Matrix reports, and the ability to edit charts. Both of these should be added before September 2010.

I'm particularly interested in:

1) browser compatibility (for instance, we have found and corrected a set of look and feel bugs for IE6)

2) load time and feedback (where we have spent a lot of time optimizing for load-time performance, but still have some work to do on the treeview load time)

3) How you feel about interacting with the builder?

 

We are really shooting for feature parity with the wizard (i.e.. the Builder create or edit everything the builder can) over the next 2 months and for GA  (in Winter'11), but also we want to know requested changes - here, or on IdeaExchange.

 

Tom Tobin

  • June 28, 2010
  • Like
  • 0

I can't seem to create a report that will allow us to show leads created in the past 48 or 72 hours. Anyone have ideas on how to add this to the filter?

 

- B

  • April 09, 2010
  • Like
  • 0

I need to create a report that will be run daily by user community. It needs to filter on a Date field

but I only want to display what occurred in the last 24 hours.

In Oracle I would do "datefield >= sysdate - 1".

 

How do I do this in SalesForce tool?

 

Thanks

Using the formula editor, how do i round up (or down) a number to x decimal places. eg:- I would like 1.239 rounded up to 2 decimal places to get the result 1.24. thanks!

Hi everyone,

 

   In my appliction i am using picklist field.My requirement is, in picklist i should not be display "-None-" option and it won't accept null values also.if any one knows this plz tell me the solution.

 

Thanks in advance,

anu..

Our app uses "junction objects" to hold many-to-many relationships.

Many of these junction objects are defined to be very small: two master-detail relationships, plus a "BothIds" field which is a string that concatenates both IDs and is defined as a external ID to get uniqueness constraints (note - salesforce, conjoined key support for many-to-many relationships would be *very* helpful so we don't have to roll our own).

Plus, they have the required "Name" field which is always set to ".".

It seems to me these objects should be at most 100 bytes, and probably much less depending on how Salesforce stores the ID datatype.

However, by comparing object counts to the "Storage Usage" screen, it is clear that "Storage Usage" counts them as about 2,000 bytes apiece.  This is consistent across orgs.

Is this 20x overhead purely for indexing?  Is there something else going on?


Here's an example of an object type that exactly matches the above description:




Message Edited by jhart on 11-19-2008 12:44 PM
  • November 19, 2008
  • Like
  • 0
Hi Folks,
I would like to make a copy of an opportunity and all its line-items when someone clicks on a custom button (via an S-Control calling a web-service using Apex)

I figure I will pass the Opportunity ID as a parameter in the webservice call, but now I'm having a problem with the cloning part.

If I initialize an Opportunity object "opp" with an SOQL select statement, and then call "opp.clone(true), am I only cloning the object that I initialized? I want to make a copy of the entire thing.  I'm missing a fundamental concept I think.

here's the Apex routine.

WebService static String duplicateOpp(String arg) {
      String test = '005E0000003Relo';
      Opportunity opp = [ select Id,Name from opportunity where id=:test];
     
      Opportunity newOpp = opp.clone( true);
     
      update newOpp;
     
       
      return 'Copied ' + newOpp.Name + ' of type ' + newOpp.Type;
    }
Hi everyone,

Is that possible to remove None from a picklist?
I want to have a string in each row of a data table that includes the Row number.

Payment 1, Payment 2, Payment 3, etc.

In js I would just use the row counter. Anything analogous in a VF datatable?

Thanks,
Steve
For some reason the standard field "Manager" (type hierarchy) on the User object seems to be limited to displaying on the User page only.  It is not visible via the API (using APEX Explorer) nor can it be selected in a standard SF report.  I see nothing in the API reference guide that suggests this particular User object field can not referenced or queried via the API. 
 
Am I missing something?  Is this not possible?  Any insight would be appreciated.  Thanks...
 
      
I'm working through Apex & .NET Basics - Understanding Execution Context

When validating the challenge I'm getting the error:
 
Challenge Not yet complete... here's what's wrong: 
The Trigger 'AccountTrigger' does not appear to be calling the AccountTriggerHandler class correctly or using isBefore or isInsert content variables.

The trigger I currently have is minimal:

trigger AccountTrigger on Account (before insert) {
    AccountTriggerHandler.CreateAccounts(Trigger.new);
}

Why would I need to check Trigger.isBefore and Trigger.isInsert if the trigger is only on before insert?

 
Hello all,

I'm stuck with the Lightning challenge "Using Apex in Components" :

here is the component :
<aura:component controller="DisplayCaseController">
	<aura:attribute name="record" type="Case[]"/>

    <aura:iteration items="{!v.record}" var="c">
	    {!c.Subject}, {!c.Description}, {!c.Subject}, {!c.Status }
	</aura:iteration>
</aura:component>
the component controller :
({
    getRecord: function(cmp){
        var action = cmp.get("c.getCaseFromId");
        action.setCallback(this, function(response){
            var state = response.getState();
            console.log(state);
            if (state === "SUCCESS") {
                cmp.set("v.record", response.getReturnValue());
            }
        });
	 $A.enqueueAction(action);
    }
})
and the apex controller (provided for the challenge)
public class DisplayCaseController {
 
    @AuraEnabled
    public static Case getCaseFromId(Id caseID) {
        if(caseID == null) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        }
            List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];
            if(cases.size() == 0) {
                return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
            } else {
                return cases[0];
        }
    }
}
and still when hitting the Check challenge button, the following error is displayed :
"Challenge not yet complete... here's what's wrong:
The component is not binding to the Case Subject value "

Could you please advise ?
Thanks a lot!