10

I have a simple SOQL query on Account which has a field Full_Address__c which is joint of Billing Street, City Zip.

When I use this field as a filter it doesn't return the records:

Example:

    String accountAddress = [SELECT Full_Address__c FROM Account LIMIT 1].Full_Address__c;
    System.debug('accountAddress '+accountAddress);
    Account acc = [SELECT id, Full_Address__c FROM Account where Full_Address__c =:accountAddress LIMIT 1];

Returns:

enter image description here

It means that the same value I am getting by query doesn't work as filter. Looks like a bug.

Formula:

    ShippingStreet & BR() & 
    ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & 
    ShippingCountry
8
  • I have noticed this previously. Currently this is not allow in salesforce. vote up for this idea success.salesforce.com/ideaView?id=08730000000BpzQAAS
    – Ratan Paul
    Commented Aug 29, 2016 at 9:54
  • This is different than the Idea link given. Here is no formula SOQL. Its simple field join or concatenation of 4 fields.
    – Ashwani
    Commented Aug 29, 2016 at 10:03
  • Ahh looks like misread it :-)
    – Ratan Paul
    Commented Aug 29, 2016 at 10:08
  • 5
    I think its issue with BR() function. When i removed it from the formula it worked just fine. For ex: ShippingStreet & ", " &ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & ", " & ShippingCountry Commented Aug 29, 2016 at 10:50
  • What if the Account you queried doesn't have the values filled in, hence why it comes back null. When you look at the field in a report or page layout is it populated? Then are you querying for that record that is populated? Commented Aug 29, 2016 at 19:31

2 Answers 2

0

Use String method escapecsv() to hanldle the New line character you are inducing in the formula field.

  String accountAddress = String.escapeCsv([SELECT Full_Address__c FROM Account LIMIT  1].Full_Address__c);
  System.debug('accountAddress '+accountAddress);
  Account acc = [SELECT id, Full_Address__c FROM Account where Full_Address__c =:accountAddress LIMIT 1];
1
  • 2
    Did you try this code yourself?
    – Ashwani
    Commented Oct 3, 2016 at 17:18
0

Just pass the particular record ID on url like Example: https://salesforce.com/pagename?id=175433#175433 Then you will get the Particular record values.

String accountAddress = [SELECT Full_Address__c FROM Account LIMIT 1].Full_Address__c;
System.debug('accountAddress '+accountAddress);
Account acc = [SELECT id, Full_Address__c FROM Account where Full_Address__c =:accountAddress LIMIT 1];
System.debug('acc '+acc);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .