• EmForce Administrator
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 3
  • 4
Hey all, I'm a pretty inexperienced Apex dev and was wondering about some best practices for looping through all object fields for their helptext metadata.

Our business case requires us to have more than 20 Lookups on a record.  Each of these lookups has their own set of fields on the record that pull in data from the lookup (Can't use formulas, otherwise cross object reference limit gets too high).  To mark which fields to put data in from the lookup, I added a search string in the help text "<<CODR" (I would put it in the description but you can't access description metadata?).  My apex class currently loops through all the object's fields and searches for the ones with the code string.  Once it grabs all of the strings, it performs the necessary steps to put in the data from the respective lookup into the field.

My biggest issue is scaling.  Our object has ~600 fields and this process takes a lot of CPU time (On average, around 75% before CPU Limit!).  I have this class activated on a before update trigger, which fires off anytime a user saves a record.  It's very slow and highly inefficient.

The data needs to be filled in only when
A. A specified Lookup is changed
B. A specified field is changed

Below is the method that is called when trigger is fired.  Every time the record is updated, this method loops through the entire object's field list.  I feel that if there was a way to only search on the criteria above, I would be able to cut down the CPU time by a large factor.  I don't know enough about Apex to figure it out though. 
-Search only lookups first, see if they're changed?
-Search only fields w/ <<CODR in helptext, see if they're changed?

Any advice?  If you need any additional information, please ask!  Thanks a ton!
	*To be used with trigger
	public void populateFieldsTrigger(Proposal__c p) {
		/*This loop goes through all fields and sees if the field is a CODR field 
		If the field is a CODR field, it gets sent to the fieldDataSorting method
		Sample search string format
		//Loop through all fields
		for(String key : fieldsMap.keySet()){
			String fieldName = fieldsMap.get(key).getDescribe().getLabel();
			//See if field has inlinehelptext to pull
				String fieldHelpText = fieldsMap.get(key).getDescribe().getInlineHelpText();
				//If field inlinehelptext has "CODR" in string, get substr numbers to split string
				if (fieldHelpText.contains(codeName)){
					Integer codeIndexStart = fieldHelpText.indexOf(codeName)+2;
					Integer codeIndexEnd = fieldHelpText.indexOf('>>');
					String codeStrOnly = fieldHelpText.substring(codeIndexStart,codeIndexEnd);
					//isProperCode checks string to make sure it's a valid format
						fieldDataSorting(codeStrOnly, p);
			catch (Exception e){
		//Once all fields are set up, call SOQL query to retrieve data and place it in targetFields

Very frustrating.
SF team, please heed this suggestion.
Search is uselsess to differentiate between the two.
Could someone that actually has the ability to fix this please respond.
Thanks kindly.
Hello Developer community.  I'm Greg, the COO of a Solar Power company on Long Island.  We have 70 employees and install hundreds of projects per year.  We are currently building out our Sales Force into a company wide "Enterprise Resouces Management" platform.

I'm seeking a developer to write a program/macro, with a few Visual Force pages, as specified in documents you can find here:

1. I would welcome the opportunity to video conference and run through everything
2. We have appropriate budget to get it done, and acknowledge that this is notable project
3. We are open to alternative ideas, but the core functionality is necessary; let's do an overview first and get on the same page
4. After discussion, happy to give login credetials to look at our existing setup, etc
5. Background: I have already written the program in Excel, as seen by the level of detail in the spec documents; now time to integrate into SF

Please feel free to write me directly at gsachs@empower-solar.com or call 516-509-3912.  Looking forward to connecting with some good people.

Sincrely, Gregory.
Very frustrating.
SF team, please heed this suggestion.
Search is uselsess to differentiate between the two.
Could someone that actually has the ability to fix this please respond.
Thanks kindly.
Very frustrating.
SF team, please heed this suggestion.
Search is uselsess to differentiate between the two.
Could someone that actually has the ability to fix this please respond.
Thanks kindly.
We are a group of wild ambitious engineers who are eager to design and implement innovative and exemplary applications on the Force.com platform.
We are practitioners with an academic background; we think and act in a practical way. We don't make code - we achieve business goals of our customers.

We are new company but we have wide experience and knowledge in Salesforce CRM implementation. We are Advanced certified professionals looking for new opportunities on Force.com platform.

Please contact us to assist your needs.

Email: support@flybeaver.com
T: +1 (408) 753-6041
Site: http://www.flybeaver.com/
Hi there,

I have more 2 yrs of Experience in salesforce, I am Salesforce Certified Developer, hands on experience in salesforce Cofiguration , Apex Class, Vf pages, Test classes, Integration, Triggers, documentation and handeling clients etc.
Currently am looking salesforce developer freelancer job.
Any help would be appreciated.

to know more about me.
My Linkedin Profile : http://www.linkedin.com/pub/abhi-tripathi-%E2%98%81/46/906/317
My Blog : http://abhithetechknight.blogspot.in/2014/05/opportunity-probability-field-value.html

Warm Regards,
Abhi Tripathi
Salesforce Certified Developer
Mobile : +91-9928833992
Skype : abhi.tripathi7


I have about 20 years experience in IT industry.  I started my career with Mainframes during Y2K times.  Later managed various projects.  PMP certified.  I am also some what exposed to client/server, java and Data Wearhousing technologies.  I have been managing projects without knowing much about technology.  I am not feeling comfortable managing projects without knowing much about technology.  I am also not growing well managerially.  I have a jeal to learn new technolgies.  I found salesforce is very interesting.  I started learning it.

Can I see a career in salesforce if I start at this stage of my career.  What type of jobs I can choose or suit for?  Please suggest.

Thanks in advance and Best Regards.