• Mickle
  • NEWBIE
  • 205 Points
  • Member since 2010

  • Chatter
    Feed
  • 8
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 22
    Replies

When I query for a large double such as:

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 2000000000

It works. 

 

 

But when I query for a larger number...

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 3000000000

 

I get a MALFORMED QUERY error:

 

Query failed: MALFORMED_QUERY: where Custom_Double_Field__c = 3000000000

Error at Row:1:Column:65
For input string: "3000000000"

 

I'm not sure what the exact maximum number that it will take before it fails to work.  How can I fix this?  Do I need to cast the larger number in my SOQL?

 

 

Hello,

I want to know whether I can see the ‘Created by’ and ‘Created date’ field for any report folder. Normally when I select any report folder, it displays the list of reports (action, report  name, description column) present in that folder. There, I could see only the 'Last Modify By' and 'Last Modified Date' for the reports. But, I need to find whether I can see the ‘Created by’ (audit field) and ‘Created date’ (audit field) fields. Kindly guide me on this.

 

 I am trying to bulk a trigger but have run into issues with the normal set/map method and therefore cannot figure out how to bulk the trigger. 
Quick background:
-before 'lead' object insert, query 'AFS_Zip__c' object to determine what the 'area team' is for the lead based on the lead's postal code referenced against a postal code range on the 'AFS_Zip__c'' object. 
-Normally I would just add all the 'trigger.new' postal codes to a set, then run one SOQL query to obtain all the 'area team' field values from the 'AFS_Zip__c' object based on 'in' set.  Because the 'AFS_Zip__c'' object provides a range of postal codes per 'area team', 'in' doesn't work. I therefore tried to add all the 'AFS_Zip__c' object'object records to a map but ran into  the '1000 record limit on SOQL queries per trigger'. because the 'AFS_Zip__c' object contains 4000+ records. 
Working code but not bulkified:
trigger TrgIns_SetDefaultValues on Lead (before insert,before update) 
{
    integer IsATFound;
    
    IsAtFound = 0;  
    
    for(Lead lead : trigger.new)    
    {       
        for (AFS_Zip__c az : [Select Name from AFS_Zip__c az where az.FromZip__c <= :lead.PostalCode and 
             az.ZipTo__c >= :lead.PostalCode]) 
        { 
            lead.Area_Team__c = az.name; 
            IsATFound = 1;  
        }//close for AFS_zip 
          
        if (IsATFound == 0) 
        { 
            lead.Area_Team__c = 'Un-Repped'; 
        }            
    }    
}

updated code that is running into '1000 record limit on SOQL queries per trigger' limit:
trigger TrgIns_SetDefaultValues_beta on Lead (before insert,before update) 
{
    map<string, string> zipMap = new map<string,string>();
     
    //creates lists of 'AFS_Zip__c' records. Issue is that the total query records size returned is 4000+
    
    for(list<AFS_Zip__c> zipList : [select id, name, FromZip__c, ZipTo__c from AFS_Zip__c])
    {    
        //for each 'AFS_Zip__c' record, determine upper and lower postal code values and 
        //map each value in the range to the 'name' field
        for (AFS_Zip__c zip : zipList)
        {         
            for(integer zipValue = integer.valueOf(zip.FromZip__c); zipValue <= integer.valueOf(zip.ZipTo__c); zipValue++)
            {
                zipMap.put(string.valueOf(zipValue), zip.name);      
            }       
        }
    }      
    
    for(Lead lead : trigger.new)    
    { 
        //if lead zip code is found in the map (~'AFS_Zip__c' postal code range'), then update the lead 'Area_Team__c 
        //field. If not, update it as 'Un-Repped'
        if(zipMap.containsKey(lead.PostalCode))
        {
            lead.Area_Team__c = zipMap.get(lead.PostalCode);
        }
        else
        {
            lead.Area_Team__c = 'Un-Repped'; 
        }  
    }   
}
------------------------------------------
Logically, I need to determine a means of only querying/mapping for the 'postal code' values from the 'trigger.new' but can't determine a method to do this because of the range. I thought about using custom settings to get around the SOQL record limits but the range check doesn't seem possible via the custom settings methods (getAll(), etc.) without using SOQL. 
Any suggestions would be greatly appreciated. Thanks!!

 

I am trying to exclude profiles from validations.

 

When I exclude System Administrator it works

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&& $Profile.Name <> "System Administrator"

 

But when I add on Accounts Receivabled it doesn't work even though I spelled it the same and copied and pasted it

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&&  $Profile.Name <> "Accounts Receivable"

 

What am I missing here!

 

Thank you in advance

  • February 01, 2011
  • Like
  • 0

So I have a custom object that is called test and within the test object i have a lookup object to enrollments. The enrollment has an autogenerated name to it and when users need to lookup to a specific enrollment they can't find it because they have to use the specific autogenerated id name that is given. Is there any way to look around this?

 

For example in the enrollment record there is a name, i want my lookup function to also look into this field rather than just looking into an id? is this possible?

Looking for some help on creating a trigger, I'm new to Saleforce.com and haven't used this type of customization before.  Here's what I need to do....

 

On an opporutnity I need to be able to track the opportunity owner role.  You are unable to do this with a basic formula field because it does not drill down on the owner ID to the additional owner fields.  Per some research, I came across a presentation that was given at Dreamforce this year in their "Formula Magic" session where they state it's a 3 step process to pull this field into an opportunity.  (http://www.slideshare.net/Salesforce/formula-magic)

 

Step 1: Create a custom lookup field to the user object
Step 2: Create a simple trigger upon insert of record or update of Owner field to populate a custom user lookup field
Step 3: Create formula fields for any field on user object based on custom user lookup field

 

I've done step 1 and created a custom lookup field in my opporutnity called "OwnerLookup".  I need help with a sample trigger for step 2 that will populate "OwnerLookup" with the opportunity owner name, that way I can easily do step 3 to pull in the role.

 

Can anybody please provide a sample trigger you feel might work?

 

Thanks in advance!

I have a rich area text field called advice_lines__c, which should pre-populate with some standard text and formatting.  I found out that you cannot set default text in a rich area text field.  So I created a workflow rule to add the default text after the record is created which works fine for my purposes.

 

In the workflow rule, I use this in the formula area of the field update which adds the text and formats it:

 

"<div align=center><b>APRVD NON-STANDARD</b> </div><br><div align=left><ul><li>Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.</li> <li>Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items. </li> <li>Only one discount is allowed per item.</li></ul><div>"

 

Now I need to add a line to this default text that pulls a value from another field called NS_Auto_Number__c.  When I use the formula editor to add the merge field, it doesn't pull the information from the field.  Instead it just shows the field name.

 

Here is my formula after I add the merge field info:

 

"<div align=center><b>APRVD NON-STANDARD</b><br>{!NS_Auto_Number} </div><br><div align=left><ul><li>Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.</li> <li>Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items. </li> <li>Only one discount is allowed per item.</li></ul><div>"

 

Here is the result:

 

APRVD NON-STANDARD
NS_Auto_Number
  • Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.
  • Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items.
  • Only one discount is allowed per item.

Here is what I need it to say:

 

APRVD NON-STANDARD
SFDC00234

  • Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.
  • Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items.
  • Only one discount is allowed per item.

 

Is this possible?  Or is there something wrong with the way I'm trying to add it to my workflow formula?

 

Thank you!!

Hello – I followed all the setup instructions closely but every time I click on the GeoCode Tab it only comes back with the message “Your Done!”. Any suggestions? Thanks in Advance. Mike L.

I have some JSON that I'm trying to deserialize using System.JSON.deserialize and am getting an unexpected error.

 

Thinking the error was made by me, I found SimonF's & Pat Patterson's awesome tool to generate the required Apex Class, and the automagically generated unit test is still failing.

 

http://json2apex.herokuapp.com/makeApex

 

Here's the code, complete with unit test that is failing

 

//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

public class JSON2Apex {

	public class Data {
		public List<List<Detections>> detections;
	}

	public class Detections {
		public String language;
		public Boolean isReliable;
		public Double confidence;
	}

	public Data data;

	
	public static JSON2Apex parse(String json) {
		return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
	}
	
	static testMethod void testParse() {
		String json = '{'+
		' \"data\": {'+
		'  \"detections\": ['+
		'   ['+
		'    {'+
		'     \"language\": \"es\",'+
		'     \"isReliable\": false,'+
		'     \"confidence\": 0.6554622'+
		'    }'+
		'   ]'+
		'  ]'+
		' }'+
		'}';
		JSON2Apex obj = parse(json);
		System.assert(obj != null);
	}
}

Could this be a reserved word issue, or something having to do with inner classes? Any help would be appreciated.

 

Thanks,

Mike

I searched around for a bit, but couldn't find an exact answer I'm looking for. Essentially, I'm trying to dynamically build the attribute (specifically the datatype of a List's members) of a Class.

 

In playing around with the Etsy API, I've build a couple of Apex Classes that mirror the data structure that is being returned. Ideally, I'm trying to use the System.JSON class to parse the results into an Object, which I'm going to do some manipulation on, prior to creating an sObject.

 

public class EtsyShop {
		public integer shop_id;
		public string shop_name;
		public string first_line;
		public string second_line;
		public string city;
		public string state;
...
	}

 

public class EtsyListing {
		public Integer listing_id;
		public string state;
		public Integer user_id;
		public Integer category_id;
		public string title;
		public string description;
                ....
	}

 When I get any results from the Etsy API, it comes wrapped up with some nice information, count of records, params used, etc. When I ask for Etsy Listings, I get a List of EtsyListings, when I ask for EtsyShops, I get a list of  EtsyShops. Right now I have hacked this together by having a Class for each results scenario. Ideally I would like this to only be one Class, with a dynamically built List of Type X.

 

{ "count": 1, "results": [ { "listing_id": 60008911, "state": "active", "user_id": 9646570, "category_id": 69170659, "title": "The Arbour Shirt - Large (bow tie sold separately)", "description": "The Rover Classics Collection evokes memories of cool mornings on the dock and lazy afternoons by the sea. Designed for the very small to the very big, our tailored jackets, fitted shirts, flirty dresses, and sophisticated accessories are the perfect additions to a well-groomed wardrobe.\r\n\r\nOur arbour shirt is perfect for casual weekends by the water. In our signature cotton madras print with scalloped lilac trim and back velcro closure with button detail.\r\n\r\nWash in cold water and hang to dry.\r\n\r\nThe Arbour Shirt can be ordered in sizes xs to xxl (please refer to sizing chart image).", "creation_tsz": 1328669426, "ending_tsz": 1339041600, "original_creation_tsz": 1288115249, "last_modified_tsz": 1328669426, "price": "30.00", "currency_code": "USD", "quantity": 1, "tags": [ "Pets", "Clothing", "Dog", "pug", "plaid", "blue", "shirt", "collar", "accessories", "bow_tie", "formal", "madras", "preppy", "pet_lover" ], "category_path": [ "Pets", "Clothing", "Dog" ], "materials": [ "cotton" ], "shop_section_id": 7299132, "featured_rank": null, "state_tsz": 1328669426, "hue": 43, "saturation": 7, "brightness": 60, "is_black_and_white": false, "url": "http://www.etsy.com/listing/60008911/the-arbour-shirt-large-bow-tie-sold?utm_source=apigeeapiconsole&utm_medium=api&utm_campaign=api", "views": 6342, "num_favorers": 164, "who_made": "i_did", "is_supply": "false", "when_made": false, "recipient": null, "occasion": null, "style": null } ], "params": { "listing_id": "60008911" }, "type": "Listing", "pagination": {} }

 

public class EtsyListingResult {
	public integer count;
	public List<Etsy.EtsyListing> results; //only difference
	public Map<String, String> params;
	public string type;
	public Map<String, String> pagination;
}

 

public class EtsyShopResult {
	public integer count;
	public List<Etsy.EtsyShop> results; //only difference
	public Map<String, String> params;
	public string type;
	public Map<String, String> pagination;
}

You can see the only difference between these two Classes is the datatype of the results list.

 

If it helps, the way these are being used is in the following code:

 

EtsyShopResult myEtsyShopResult = (EtsyShopResult)JSON.deserialize(responseBody, EtsyShopResult.class);

 

Any help would be appreciated. I'm just trying to make this code as resusable and scalable as possible, and I feel like there are a couple of higher level techniques that I'm not fully grasping. :) 

 

 

  • February 19, 2012
  • Like
  • 0

I've submitted a case through my developer org, but it's taking a while to resolve. (It's really hard to get me on the phone as I'm in and out of meetings quite frequently). I was curious if anyone else was experiencing this issue. I've tested it in a Sandbox as well as my Developer org, in both Firefox and Chrome, but maybe I am crazy and there is something I'm missing.

 

Basically, if a multiselect picklist has a picklist value with a single (') or double quote ("), and you try to edit the field via an inline edit, the picklist values with quotes in them will be displayed as available options and will also (if applicable) selected options as well. This leads to a situation where you can select the same value twice. (It would appear as though even if you repeat these steps, it will not save the same field value more than twice).

 

To recreate, create a Multi Select Picklist on any object.

 

Include the following possible options (make sure you include single quotes and double quotes):

 

  1. Test
  2. Test's
  3. Multiple Test's
  4. Double"s
Select value #1, and save the record. Now, via an inline edit, add option #2, and save the record. It will succesfully add the value, however, do ANOTHER inline edit, and you will see #2, #3, and #4 as available options (even though #1 and #2 have already been selected). If you select #2 (a second time, as it's already been selected) and then save the record, the field will now display this value TWICE. 
I've isolated it to only the single and double quote characters.
I'm curious if anyone has seen this issue before, or if anyone internally can make sure it gets filed as bug.
SFDC Case# 05308385
Thanks,

 

Has anyone had any success implementing a work around to not being able to create workflow based on a lead's Unread by Owner status?

 

Issue is similar to this: https://sites.secure.force.com/success/ideaview?id=08730000000BqU2AAK

 

Ideally, I'd like to be able to report on which users are reading their leads quickly, and which aren't.

 

What comes to mind quickly for implenting a work around would be either an analytic snapshot (running every day), or possibly scheduling an Apex job see if this value has changed.

 

Both seem less than ideal, so I'm asking the great minds here if there are any other possible workarounds.

  • January 11, 2011
  • Like
  • 0

Alright, I have very little experience coding with Apex (or any other programming language for that matter), however I am generally alright at modifying code. However, there is an area I am having trouble with, and even though I know a lot of people have had a very similar problem, I cannot seem to fix this.

 

I have a custom object created, that I am trying to link to the Lead object, using a lookup field. I have it set up perfectly manually, however I want to automatic this process using Apex, I get an error message.

 

Lead Object Fields:
PostalCode 
ACZipCode API Name:ACZipCode__c Type: Lookup(ACZipCode)

 

Custom Object ACZipCode fields API Name: ACZipCode__c

ZipCode

API Name:ZipCode__c

Type:Text(5)

 

Apex Trigger needing work:

trigger GetZipCode on Lead (after insert, after update) {
for (Lead a : Trigger.new) {a.ACZipCode__c = a.PostalCode; }}

 

Error message:

Review all error messages below to correct your data.
Apex trigger GetZipCode caused an unexpected exception, contact your administrator: GetZipCode: execution of AfterUpdate caused by: System.StringException: Invalid id: 43225: Trigger.GetZipCode: line 2, column 29

 

I believe what it is doing is passing the raw zipcode number though, when it really needs the ACZipCode ID number. I just don't know how to fix this. Again, everything works perfectly if I disable the Apex trigger, and just manually type in the 5 digit zipcode (I'm guessing it does the lookup behind the scenes).

 

Any help would be appreciated, thanks!

 

 

  • November 03, 2010
  • Like
  • 0

I have some JSON that I'm trying to deserialize using System.JSON.deserialize and am getting an unexpected error.

 

Thinking the error was made by me, I found SimonF's & Pat Patterson's awesome tool to generate the required Apex Class, and the automagically generated unit test is still failing.

 

http://json2apex.herokuapp.com/makeApex

 

Here's the code, complete with unit test that is failing

 

//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

public class JSON2Apex {

	public class Data {
		public List<List<Detections>> detections;
	}

	public class Detections {
		public String language;
		public Boolean isReliable;
		public Double confidence;
	}

	public Data data;

	
	public static JSON2Apex parse(String json) {
		return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
	}
	
	static testMethod void testParse() {
		String json = '{'+
		' \"data\": {'+
		'  \"detections\": ['+
		'   ['+
		'    {'+
		'     \"language\": \"es\",'+
		'     \"isReliable\": false,'+
		'     \"confidence\": 0.6554622'+
		'    }'+
		'   ]'+
		'  ]'+
		' }'+
		'}';
		JSON2Apex obj = parse(json);
		System.assert(obj != null);
	}
}

Could this be a reserved word issue, or something having to do with inner classes? Any help would be appreciated.

 

Thanks,

Mike

I have some JSON that I'm trying to deserialize using System.JSON.deserialize and am getting an unexpected error.

 

Thinking the error was made by me, I found SimonF's & Pat Patterson's awesome tool to generate the required Apex Class, and the automagically generated unit test is still failing.

 

http://json2apex.herokuapp.com/makeApex

 

Here's the code, complete with unit test that is failing

 

//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

public class JSON2Apex {

	public class Data {
		public List<List<Detections>> detections;
	}

	public class Detections {
		public String language;
		public Boolean isReliable;
		public Double confidence;
	}

	public Data data;

	
	public static JSON2Apex parse(String json) {
		return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
	}
	
	static testMethod void testParse() {
		String json = '{'+
		' \"data\": {'+
		'  \"detections\": ['+
		'   ['+
		'    {'+
		'     \"language\": \"es\",'+
		'     \"isReliable\": false,'+
		'     \"confidence\": 0.6554622'+
		'    }'+
		'   ]'+
		'  ]'+
		' }'+
		'}';
		JSON2Apex obj = parse(json);
		System.assert(obj != null);
	}
}

Could this be a reserved word issue, or something having to do with inner classes? Any help would be appreciated.

 

Thanks,

Mike

We were excited to read about this new class and method in the Summer 11 releas.  However, it doesn't look like this method behaves as it should. 

 

Documentation states:


Returns the URL of the Salesforce instance.
For example, https://na1.salesforce.com.

 

If I execute the following line from the system log....


String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();

System.debug('baseUrl =' + baseUrl);

 

This produces this output...

baseUrl = https://na8.salesforce.com/apexdebug/SystemLog.apexp

 

which is incorrect because it includes 'apexdebug/SystemLog.apexp'.

 

Even worse, if I run the same code from a controller tied to a visual force page, I get...

 

baseUrl=https://c.na8.visual.force.com/services/Soap/class/CreditPersonsWS

Is this a bug or am I misunderstanding what the purpose of this method is?

 

Thanks 

I've submitted a case through my developer org, but it's taking a while to resolve. (It's really hard to get me on the phone as I'm in and out of meetings quite frequently). I was curious if anyone else was experiencing this issue. I've tested it in a Sandbox as well as my Developer org, in both Firefox and Chrome, but maybe I am crazy and there is something I'm missing.

 

Basically, if a multiselect picklist has a picklist value with a single (') or double quote ("), and you try to edit the field via an inline edit, the picklist values with quotes in them will be displayed as available options and will also (if applicable) selected options as well. This leads to a situation where you can select the same value twice. (It would appear as though even if you repeat these steps, it will not save the same field value more than twice).

 

To recreate, create a Multi Select Picklist on any object.

 

Include the following possible options (make sure you include single quotes and double quotes):

 

  1. Test
  2. Test's
  3. Multiple Test's
  4. Double"s
Select value #1, and save the record. Now, via an inline edit, add option #2, and save the record. It will succesfully add the value, however, do ANOTHER inline edit, and you will see #2, #3, and #4 as available options (even though #1 and #2 have already been selected). If you select #2 (a second time, as it's already been selected) and then save the record, the field will now display this value TWICE. 
I've isolated it to only the single and double quote characters.
I'm curious if anyone has seen this issue before, or if anyone internally can make sure it gets filed as bug.
SFDC Case# 05308385
Thanks,

 

 

Hello, I have seen a few threads from last year which where stating  that when a Visual force dashboard is refreshed by clicking on the button on the home page the visualforce component disappears.

 

I haven't been able to find a solution to this and was wondering if there is anyone has found a solution to this?

 

For some reason scheduled dashboard refresh updates the page fine, but this can only be run once a day. My organisation will need to refresh the dashboard in question several times a day.

 

 

 

 

Hi all,

 

When you create a field of type number, you are allowed to enter a number of digits before and after the decimal.  My understanding was that if you entered  a value with too many digits before or after the decimal place, you would get an error on insert/update.  However, that is not the case.

 

 

MyObject__c mo = new MyObject__c();
mo.Name = 'Testing rounding';
mo.Temporary__c = 123.4567890; //This field defined as Number(10,2)
insert mo;
System.debug('val = ' + mo.Temporary__c);

 

 

I would expect one of two outcomes from the above code:

 

1) Exception when I try to insert.

or

2) Truncate or round the number accordingly.

 

However, instead the debug statement prints out:

 

 

14:42:44.063|USER_DEBUG|[6]|DEBUG|val = 123.4567890

 

 

So...what does limiting the number of digits before/after the decimal place even do?  Do I really have to manually chop this number off at 2 decimal places every time I want to use it?

 

Thanks!

  • March 07, 2011
  • Like
  • 0

Hi,

 

I am relatively new to Apex, and have tried but it appears not very well to create a simple trigger. I simply have 2 custom contact fields (one plain text and one a Lookup field). If the plain text matches a string of text I just need to populate the lookup field with a corresponding ID of a custom object. I have tried all sorts using code samples from the boards, etc. but simply this is what I am trying to achieve:

 

trigger myTrigger on Contact (after insert, after update){
if(Contact.Affiliate__c = '123')
Contact.Affiliate_Source__c = 'a0BQ0000003TAAo';
}

 

I will update contacts using Lead conversion and also mass import using the Apex data loader, so I presume any solution will work on each contact upsert.

 

I know there are more complex functions that include looking up the ID, etc. but I am just trying to get this working in it's most basic form - and would appreciate any help. I am sure it's really simple :)

When I query for a large double such as:

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 2000000000

It works. 

 

 

But when I query for a larger number...

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 3000000000

 

I get a MALFORMED QUERY error:

 

Query failed: MALFORMED_QUERY: where Custom_Double_Field__c = 3000000000

Error at Row:1:Column:65
For input string: "3000000000"

 

I'm not sure what the exact maximum number that it will take before it fails to work.  How can I fix this?  Do I need to cast the larger number in my SOQL?

 

 

Hello,

I want to know whether I can see the ‘Created by’ and ‘Created date’ field for any report folder. Normally when I select any report folder, it displays the list of reports (action, report  name, description column) present in that folder. There, I could see only the 'Last Modify By' and 'Last Modified Date' for the reports. But, I need to find whether I can see the ‘Created by’ (audit field) and ‘Created date’ (audit field) fields. Kindly guide me on this.

 

 I am trying to bulk a trigger but have run into issues with the normal set/map method and therefore cannot figure out how to bulk the trigger. 
Quick background:
-before 'lead' object insert, query 'AFS_Zip__c' object to determine what the 'area team' is for the lead based on the lead's postal code referenced against a postal code range on the 'AFS_Zip__c'' object. 
-Normally I would just add all the 'trigger.new' postal codes to a set, then run one SOQL query to obtain all the 'area team' field values from the 'AFS_Zip__c' object based on 'in' set.  Because the 'AFS_Zip__c'' object provides a range of postal codes per 'area team', 'in' doesn't work. I therefore tried to add all the 'AFS_Zip__c' object'object records to a map but ran into  the '1000 record limit on SOQL queries per trigger'. because the 'AFS_Zip__c' object contains 4000+ records. 
Working code but not bulkified:
trigger TrgIns_SetDefaultValues on Lead (before insert,before update) 
{
    integer IsATFound;
    
    IsAtFound = 0;  
    
    for(Lead lead : trigger.new)    
    {       
        for (AFS_Zip__c az : [Select Name from AFS_Zip__c az where az.FromZip__c <= :lead.PostalCode and 
             az.ZipTo__c >= :lead.PostalCode]) 
        { 
            lead.Area_Team__c = az.name; 
            IsATFound = 1;  
        }//close for AFS_zip 
          
        if (IsATFound == 0) 
        { 
            lead.Area_Team__c = 'Un-Repped'; 
        }            
    }    
}

updated code that is running into '1000 record limit on SOQL queries per trigger' limit:
trigger TrgIns_SetDefaultValues_beta on Lead (before insert,before update) 
{
    map<string, string> zipMap = new map<string,string>();
     
    //creates lists of 'AFS_Zip__c' records. Issue is that the total query records size returned is 4000+
    
    for(list<AFS_Zip__c> zipList : [select id, name, FromZip__c, ZipTo__c from AFS_Zip__c])
    {    
        //for each 'AFS_Zip__c' record, determine upper and lower postal code values and 
        //map each value in the range to the 'name' field
        for (AFS_Zip__c zip : zipList)
        {         
            for(integer zipValue = integer.valueOf(zip.FromZip__c); zipValue <= integer.valueOf(zip.ZipTo__c); zipValue++)
            {
                zipMap.put(string.valueOf(zipValue), zip.name);      
            }       
        }
    }      
    
    for(Lead lead : trigger.new)    
    { 
        //if lead zip code is found in the map (~'AFS_Zip__c' postal code range'), then update the lead 'Area_Team__c 
        //field. If not, update it as 'Un-Repped'
        if(zipMap.containsKey(lead.PostalCode))
        {
            lead.Area_Team__c = zipMap.get(lead.PostalCode);
        }
        else
        {
            lead.Area_Team__c = 'Un-Repped'; 
        }  
    }   
}
------------------------------------------
Logically, I need to determine a means of only querying/mapping for the 'postal code' values from the 'trigger.new' but can't determine a method to do this because of the range. I thought about using custom settings to get around the SOQL record limits but the range check doesn't seem possible via the custom settings methods (getAll(), etc.) without using SOQL. 
Any suggestions would be greatly appreciated. Thanks!!

 

I am trying to exclude profiles from validations.

 

When I exclude System Administrator it works

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&& $Profile.Name <> "System Administrator"

 

But when I add on Accounts Receivabled it doesn't work even though I spelled it the same and copied and pasted it

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&&  $Profile.Name <> "Accounts Receivable"

 

What am I missing here!

 

Thank you in advance

  • February 01, 2011
  • Like
  • 0

So I have a custom object that is called test and within the test object i have a lookup object to enrollments. The enrollment has an autogenerated name to it and when users need to lookup to a specific enrollment they can't find it because they have to use the specific autogenerated id name that is given. Is there any way to look around this?

 

For example in the enrollment record there is a name, i want my lookup function to also look into this field rather than just looking into an id? is this possible?

Looking for some help on creating a trigger, I'm new to Saleforce.com and haven't used this type of customization before.  Here's what I need to do....

 

On an opporutnity I need to be able to track the opportunity owner role.  You are unable to do this with a basic formula field because it does not drill down on the owner ID to the additional owner fields.  Per some research, I came across a presentation that was given at Dreamforce this year in their "Formula Magic" session where they state it's a 3 step process to pull this field into an opportunity.  (http://www.slideshare.net/Salesforce/formula-magic)

 

Step 1: Create a custom lookup field to the user object
Step 2: Create a simple trigger upon insert of record or update of Owner field to populate a custom user lookup field
Step 3: Create formula fields for any field on user object based on custom user lookup field

 

I've done step 1 and created a custom lookup field in my opporutnity called "OwnerLookup".  I need help with a sample trigger for step 2 that will populate "OwnerLookup" with the opportunity owner name, that way I can easily do step 3 to pull in the role.

 

Can anybody please provide a sample trigger you feel might work?

 

Thanks in advance!

I have a rich area text field called advice_lines__c, which should pre-populate with some standard text and formatting.  I found out that you cannot set default text in a rich area text field.  So I created a workflow rule to add the default text after the record is created which works fine for my purposes.

 

In the workflow rule, I use this in the formula area of the field update which adds the text and formats it:

 

"<div align=center><b>APRVD NON-STANDARD</b> </div><br><div align=left><ul><li>Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.</li> <li>Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items. </li> <li>Only one discount is allowed per item.</li></ul><div>"

 

Now I need to add a line to this default text that pulls a value from another field called NS_Auto_Number__c.  When I use the formula editor to add the merge field, it doesn't pull the information from the field.  Instead it just shows the field name.

 

Here is my formula after I add the merge field info:

 

"<div align=center><b>APRVD NON-STANDARD</b><br>{!NS_Auto_Number} </div><br><div align=left><ul><li>Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.</li> <li>Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items. </li> <li>Only one discount is allowed per item.</li></ul><div>"

 

Here is the result:

 

APRVD NON-STANDARD
NS_Auto_Number
  • Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.
  • Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items.
  • Only one discount is allowed per item.

Here is what I need it to say:

 

APRVD NON-STANDARD
SFDC00234

  • Second Advice Line is Mandatory. Please enter advice lines exactly as shown above in bold.
  • Incentive Advice Line must be on a separate permanent advice line with an 'A' in the SP INS field and must appear directly below the item code on non-art items and below the Art ID line on art items.
  • Only one discount is allowed per item.

 

Is this possible?  Or is there something wrong with the way I'm trying to add it to my workflow formula?

 

Thank you!!

Hi,

 

Is there a way I can create a button (like a <li> tag in HTML) in the Formula (text).

I have a formula as below but instead of a dash I want it to be a <li>.

 

IF(INCLUDES(Documentary_Requirements__c,"Proof of Billing"), "- Proof of Billing" & BR(),"")

 

Actual Result:  - Proof of Billing

Desired Result: <li> Proof of Billing

 

Thanks in Advance

Del

Has anyone had any success implementing a work around to not being able to create workflow based on a lead's Unread by Owner status?

 

Issue is similar to this: https://sites.secure.force.com/success/ideaview?id=08730000000BqU2AAK

 

Ideally, I'd like to be able to report on which users are reading their leads quickly, and which aren't.

 

What comes to mind quickly for implenting a work around would be either an analytic snapshot (running every day), or possibly scheduling an Apex job see if this value has changed.

 

Both seem less than ideal, so I'm asking the great minds here if there are any other possible workarounds.

  • January 11, 2011
  • Like
  • 0

Hi All,

 

We are trying to implement Find Nearby  in our Sandbox (Enterprise edition) and when we click on the "Locate Lead" link it takes us to a screen that says "You're Done!" but it does not show the map. 

 

Thinking perhaps there is another application we need to install or a setting we need to change, but not sure what that would be.

 

TIA,

David

Alright, I have very little experience coding with Apex (or any other programming language for that matter), however I am generally alright at modifying code. However, there is an area I am having trouble with, and even though I know a lot of people have had a very similar problem, I cannot seem to fix this.

 

I have a custom object created, that I am trying to link to the Lead object, using a lookup field. I have it set up perfectly manually, however I want to automatic this process using Apex, I get an error message.

 

Lead Object Fields:
PostalCode 
ACZipCode API Name:ACZipCode__c Type: Lookup(ACZipCode)

 

Custom Object ACZipCode fields API Name: ACZipCode__c

ZipCode

API Name:ZipCode__c

Type:Text(5)

 

Apex Trigger needing work:

trigger GetZipCode on Lead (after insert, after update) {
for (Lead a : Trigger.new) {a.ACZipCode__c = a.PostalCode; }}

 

Error message:

Review all error messages below to correct your data.
Apex trigger GetZipCode caused an unexpected exception, contact your administrator: GetZipCode: execution of AfterUpdate caused by: System.StringException: Invalid id: 43225: Trigger.GetZipCode: line 2, column 29

 

I believe what it is doing is passing the raw zipcode number though, when it really needs the ACZipCode ID number. I just don't know how to fix this. Again, everything works perfectly if I disable the Apex trigger, and just manually type in the 5 digit zipcode (I'm guessing it does the lookup behind the scenes).

 

Any help would be appreciated, thanks!

 

 

  • November 03, 2010
  • Like
  • 0
Hello – I followed all the setup instructions closely but every time I click on the GeoCode Tab it only comes back with the message “Your Done!”. Any suggestions? Thanks in Advance. Mike L.