Monthly Archives: August 2014

Apex Tip: How to remove the action column on standard related List

Many customers ask to remove the actions (Edit, Del) from related list and the natural way to solve that is by removing Edit and Del permission on the profile.

However sometimes you need that the user have those permissions. For instance, when the user trigger a web service that update the record.

So, here the magic, using a simple line of jQuery:

Where lContacts is the ID of the related list.

Of course this need to add javascript to the page and hence it’s only possible to be used on visualforce.

Enjoy :)

About Martin Borthiry

I’m a fully trained and qualified software engineer with more than 15 years of varied experience, specialized in frontend performance, web developing , cloud computing, salesforce, as well as CRM functionalties and Social Networks. Specialties: Salesforce.com Platform & Web Performance Optimization. Salesforce.com Developer and Administrator Certified. Senior Frontend, Javascript and HTML5. Heavy Ajax WebApps Mobile WebApps – Phonegap Webapps Developer (Php/Django/Python) Team Work & Managment

Apex Tip: How to keep values during Batch iterations and get the total amount of records processed on final

As you know the Apex Batch structure has 3 basic method:

  • Start : This is only executed on the first iteration before execute
  • Execute: This method runs for each scope (more info about scope here) you defined
  • Finish : this method runs after the last scope execution

Suppose now that you want to know the total amount of records processed. The natural approach to that is to have a variable and increment on each iteration, something like this:

However,  total will returns 0.  The reason of that is Apex Batch reset attributes on each iteration  :(.

The solution for that is to include the interface Database.Stateful in order to keep the variable status over the whole execution.

Finally, you’ll have something like this:

 

About Martin Borthiry

I’m a fully trained and qualified software engineer with more than 15 years of varied experience, specialized in frontend performance, web developing , cloud computing, salesforce, as well as CRM functionalties and Social Networks. Specialties: Salesforce.com Platform & Web Performance Optimization. Salesforce.com Developer and Administrator Certified. Senior Frontend, Javascript and HTML5. Heavy Ajax WebApps Mobile WebApps – Phonegap Webapps Developer (Php/Django/Python) Team Work & Managment