When Do You Need a Developer for a Migration to Salesforce?

In many instances, the data to be migrated in Salesforce is simple enough that it can be imported with a tool like Jitterbit or the Salesforce Data Import Wizard.

There are some situations though, when the migration might be difficult or cumbersome to implement with one of these tools. It’s likely that in these cases developing an application will be more cost-effective than the standard approach.

Here are a few cases when a Salesforce developer should create an application to process the data import by using Visualforce and Apex:

How to Schedule a Batch Job every 30 Minutes

  1. Create a class that implements the Batchable and Schedulable interfaces
  2. Connect to the Developer Console
  3. Go to Debug / Open Execute Anonymous Window
  4. Enter this code and execute it
  5. Monitor your scheduled jobs
  6. If you need to run the job more often, like every 15 minutes, create two additional jobs:one for 15 minutes, and one for 45 minutes.

System.schedule('myJob_00', '0 0 * * * ?', new myClass());
System.schedule('myJob_30', '0 30 * * * ?', new myClass());

by Vladimir Martinov

Pledge Rollup Unmanaged Package

Some non-profits want to rollup pledges (donations with StageName=’Pledged’). NPSP provides user-defined rollups for ‘Posted’ donations.

Daizylogik has built an unmanaged package for Pledge Rollups on Accounts and Contacts for the current and previous calendar and fiscal years. It also, rolls up the Payments for pledges.

You can install it from here:
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t61000000gOV2
The source code is available here: https://github.com/daizylogik/DZ_DEV.git

Post Installation Instructions:
1. add the following fields to the Account and Contact page layout:
Pledge_Payment_Amt_Recvd_Current_CY__c
Pledge_Payment_Amt_Recvd_Current_FY__c
Pledge_Payment_Amt_Recvd_Previous_CY__c
Pledge_Payment_Amt_Recvd_Previous_FY__c
Total_Pledges_Current_CY__c
Total_Pledges_Current_FY__c
Total_Pledges_Previous_CY__c
Total_Pledges_Previous_FY__c

2. Edit the Search Layout for the Opportunities, and the add the Calculate Pledge Totals button, so you can run the rollups on demand.

3. If you would like to schedule the rollup job, use the PledgeRollupBatch class.

by Vladimir Martinov

 

How to Override the Edit Button Based on Record Type

This is how you can override the Edit action for Book__c custom object. If the record type is Alpha you will be directed to a new page, otherwise you go to the standard edit page.

<apex:page standardController="DaizyLogik__Book__c" action="{!URLFOR(
CASE(DaizyLogik__Book__c.RecordType.Name, 'Alpha', $Page.BookAlpha,
'/' + DaizyLogik__Book__c.Id + '/e?nooverride=1'),
DaizyLogik__Book__c.Id) }">

<apex:variable value=”{!DaizyLogik__Book__c.RecordType.Name}” var=”recTypeName”/>
</apex:page>

by Vladimir Martinov

 

How to check if a Salesforce object has changed

When working with Apex triggers, it will sometimes be useful to know whether your
object has changed. You can write a function where you check every field by hard-coding them, but there is a more elegant way to accomplish this:


private static boolean hasChanged(YourObjectClass oldObject, YourObjectClass newObject) {

boolean changed = false;
Map fieldsMap = Schema.SObjectType.YourObjectClass.fields.getMap();
for (String key : fieldsMap.keySet()) {
Schema.DescribeFieldResult result = fieldsMap.get(key).getDescribe();

if (oldObject.get(result.getName()) != newObject.get(result.getName())) {
changed = true;
break;
}

}
return changed;
}

by Vladimir Martinov