To write functional Apex unit tests for methods having the future annotation, all you need to do is use Test.startTest() and Test.stopTest(). The general structure of your testMethod will look like the following.
Whether it's scheduled Apex or @future Apex, calling Test.stopTest() will cause those methods to run in sequence in your test method. Test.stopTest() then allows you to validate the results of @future Apex using normal means.
Insights and lessons learned from designing and implementing cloud solutions on the Salesforce1 Platform. Side adventures into Heroku with Ruby on Rails apps also included.
Friday, December 20, 2013
Wednesday, December 4, 2013
Mark Read Checkbox in Field Permissions for Salesforce Profile with Bookmarklet
Below is a functional bookmarklet that you can use to mark the Read checkbox for every single field in the Field Permissions section of an object's settings within a Salesforce Profile.
To use the bookmarklet:
- Drag the link ("bookmarklet") on to your browser's bookmarks bar
- Open an object settings page within a Salesforce Profile
- Click the bookmarklet in your browser's bookmarks bar
Note: This was tested with Chrome on Windows 8 in Salesforce Winter '14.
Labels:
hack,
JavaScript,
Salesforce
Tuesday, December 3, 2013
Deploying Destructive Changes Using Workbench
Sometimes, especially in the case of custom Apex or Visualforce, a Salesforce admin or developer needs to delete components from an org. However, Salesforce's user-friendly change sets feature does not allow admins to propagate component deletions. The only semi-automated alternative to performing these deletions, especially in production orgs, is to leverage the metadata API.
Fortunately, with the availability of Workbench on Developer Force, the steps required for deploying destructive changes (that delete components) are pretty simple:
Fortunately, with the availability of Workbench on Developer Force, the steps required for deploying destructive changes (that delete components) are pretty simple:
- Create a package.xml file
- Create a destructiveChanges.xml file
- Bundle the two files together in a .zip file
- Deploy the .zip package using Workbench
As you can see from this sample .zip package, the files are fairly simple and straightforward. Multiple types of metadata can be removed with a single package.
The exact steps for deploying using Workbench 29.0.1 are:
- Open the migration menu, then click Deploy
- Click Browse... and select the .zip package file
- Mark the "Rollback On Error" checkbox
- Mark the "Single Package" checkbox
- Mark the "Run All Tests" checkbox
- Click Next
- Review the deployment options, then click Deploy
The results, successful or otherwise, will be displayed in Workbench for you to review once the deployment process is complete.
Labels:
Apex,
API,
Force.com,
metadata,
Salesforce,
Visualforce
Subscribe to:
Posts (Atom)