Posts

Showing posts from 2015

Customise standard validation error messages in approval process submission

Image
When a record is submitted for approval from items to approve section/ or through a custom button from visualforce page, if there are any validation errors, Salesforce redirects the user to a new page as shown in below screenshot: You can customise the error message in trigger using addError() method.   Account acctObj = Trigger.new[0]; String errorMessage = 'Click here to go to Account, <a href="https://www.blogger.com/'+URL.getSalesforceBaseUrl().toExternalForm()+'/'+acctObj.Id+'">here</a>'; acctObj.addError('<b><span style="color: red;">'+errorBody+'</span></b>');

Export Salesforce standard Report in Visualforce page

Many of us might be developing some custom code to export data to excel. You can use this simple hack to generate excel from Salesforce standard report. String reportDeveloperName = 'Sample_Report'; reports = new List ([select developername,id from report where developername= :reportDeveloperName]); mailLogReportUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + reports[0].id + '?pv0=' + pv0 + '&export=1&enc=UTF-8&xf=xls';