Cleaning up data makes me sooo very happy. It’s one of the things that I secretly love most about being a Salesforce Admin. I love running reports and finding problems and fixing them. Not just with fantastic tools like DemandTools (by CRMFusion– what the heck would I do without this tool!) but also data cleanup tools within Salesforce, like Workflows. So I’m even more excited that I’ll soon be able to do even more with Apex.
One of the things that will be on the top of my list is updating data in one object based on an update in another. You can already do that using workflows, but only with objects that are related through Master-Detail relationships. I need MORE POWER!
My First Apex Trigger
I have a custom field (blocked__c) on both the Account and Contact objects. These fields are used when we want to block (fancy that) an account or contact from ordering within our back-end ERP, MS Dynamics NAV. When someone leaves a company, we block the contact in either NAV or Salesforce — they update each other through another fantastic tool Jitterbit. When we don’t want to sell to the company (they’re no longer in business, or they havn’t paid their bills), then we block the account.
Wouldn’t it be great if when I blocked an account, that all the related contacts were automatically blocked too! Yes I tell you! Yes indeed it would be wonderful! And you can’t do that with a workflow. Right now we have to do this manually. Sad, sad, sad. This potentially leads to us marketing to people who will never receive our catalogs. Not good.
So I can’t wait to figure out how to do that. Stay tuned and I’ll post my code when I’m done. Whoo hoo! I tell ya, this power could go to my head. Except that I don’t have it yet, so I guess the world is safe….for now (bwaaaa haa haa!).
What is an ERP?
An ERP or Enterprise resource planning system is software that is used to manage many business processes, such as planning, purchasing, inventory, sales, marketing, finance, human resources, etc. Examples include MS Dynamics NAV, MS Dynamics GP, NetSuite, SAP, FinancialForce, Sage.
Read more about ERPs on Wikipedia.