EC Payroll, Don’t Overcomplicate It!

Jeroen Wielens
Global Delivery Director
SAP SuccessFactors at 1218 Global HR Solutions
jeroen.wielens@1218hrs.com

EC Payroll is one of the most discussed and misunderstood modules in the SAP SuccessFactors space. I’ve seen multiple articles on Twitter and LinkedIn over the last few weeks that are about EC  Payroll SOW’s, who’s including what, glaring misses and what vendor is better than others. I even tried to listen to a podcast by a bunch of EC consultants that I had the pleasure to work with before, talking about organizing Payroll Palooza. It is a scary thought for a payroll guy to hear HR guys wanting to make payroll like a rock concert.

Read more

Salesforce Mobile Architecture: Exam Afterthoughts & Tips by Amnon Kruvi

Amnon Kruvi, Salesforce Solutions Architect
1218 Global – EMEA
Amnon.Kruvi@1218global.com

I took a leap of faith and dove into the world of mobile applications on the Salesforce platform. After passing the Salesforce Certified Mobile Solutions Architecture Designer exam, I wanted to share some thoughts (and tips).

Read more

Why Invocable Methods Could Spell the End for Apex Triggers by Amnon Kruvi

Amnon Kruvi, Salesforce Solutions Architect
1218 Global – EMEA
Amnon.Kruvi@1218global.com

If you have written code on Salesforce before, chances are you have built an Apex trigger in your lifetime. However, on a platform that prides itself on its Clicks, Not Code mentality, the question must be begged: Are triggers the best solution to automate logic that cannot be handled by out-of-the-box declarative tools?

The Role of the System Administrator

Before we delve into this question, there is something that needs to be made clear: What is a system administrator?

Sure, a good system admin will configure a Salesforce org, manage its users and apps, and resolve issues on the system. But more than that, the administrator is often the person who decides what route a user needs to take in order to fulfill their tasks – what apps should be used, and how those apps should operate to achieve the best results for the business. And, if the need arises, the administrator can play the role of the app builder – modifying system behavior by creating workflow rules, processes, flows, and more.

Or in short: a fantastic, knowledgeable, capable resource.

Source: XKCD. Altered to remove swearing – we’re trying to be professional here.

And our role, as developers, is to allow administrators to achieve these requirements with as much flexibility as they require.

The Code Problem

Flexibility is where code fails administrators. When they install a trigger, they cannot edit its code. And when their requirements inevitably change – the code does not. When this happens, the only resort is to call upon the developer again (assuming they are still available), make that change, and go through an entire release cycle.

This includes small changes to the flow of the code – should this procedure run for every contact that goes into the system, or only for a certain record type? Imagine the frustration of having to call up the development team just because you installed a new app, which came with its own record types, and you need to make code changes just to decide which of them your procedure should process.

Invocable Methods are a Middle Ground

But what if a developer could write a procedure, and allow the system administrator to decide the conditions in which to execute it? That is exactly the issue Salesforce aims to resolve with their Invocable Methods mechanism.

These methods can be executed using two popular declarative tools: Process Builder, and Lightning Flow. They are written almost exactly like normal methods, can accept input parameters (with a few caveats), and can produce an output value. Here is an example:

@InvocableMethod(Label='Count Open Cases' Description='Returns a count of open cases for the provided contact')

public static List<Decimal> countOpenCases(List<Id> contactId) {

//Query the amount of open cases for all contacts

Map<Id, Decimal> mapResults = new Map<Id, Decimal>();

for (AggregateResult ar : [SELECT ContactId con, COUNT(Id) cnt

FROM Case

WHERE ContactId IN :contactId

AND IsClosed = false

GROUP BY ContactId]) {

//Store the amount of open cases for each contact in a map

mapResults.put((Id)ar.get('con'), (Decimal)ar.get('cnt'));

}

//Sort the amount of open cases into a list with the same order as the contactId list

List<Decimal> res = new List<Decimal>();

List<Contact> contactsToUpdate = new List<Contact>();

for (Id conId : contactId) {

Decimal val = mapResults.get(conId);

if (val == null) {

val = 0.0;

}

res.add(val);

contactsToUpdate.add(new Contact(Id = conId, Open_Cases__c = val));

}

//Store the amount of open cases on the contact records

update contactsToUpdate;

return res;

}

The function accepts an input (a list of contact IDs), produces an output (a list of open cases for each contact on the list), and even has a nifty label and description annotation which is bound to come in handy for app builders, as well as whoever ends up maintaining the code.

An administrator could use Process Builder to trigger this piece of code whenever a certain event happens to a record (for example, when a new case is created) and only when certain criteria are met (such as clients with a limited service contract) using the built-in criteria and decision steps built into process builder and flows. They can also store the return values back into flow variables and use them later on in decision steps!

This means Process Builder and Lightning Flow have become tools that can orchestrate the flow of logic and attach conditions to whether each method will be executed. This has long been the job of triggers, but now that power lies within the grasp of the declarative app builders. When they add a new record type to the organization, they can modify the process themselves and configure their preferred handling; they can create their own custom settings to toggle certain functionality on or off; they can trigger the code on record creation and record updates, and even limit it to only run when specific fields have been changed.

Getting Technical

So, what are the bits you need to know about creating Invocable Methods? Well, that’s simple!

To start with, you just need to add the @InvocableMethod annotation to any function. The annotation accepts two parameters: Label and Description. Use these to create a clear idea of what your method does – and they will show inside the process and flow builders.

Your Invocable Method can accept either no parameters, or one parameter. That parameter must be a list of values, and not a single instance. This is because flows and processes are bulkified, and the data from several instances may be sent to your method at once. This is a great thing when considering performance and governor limits!

If you need more than one parameter, you can create your own inner class with its own fields and accept a list of that class. The class can have many member variables, and those you mark with the annotation @InvocableVariable will be shown as possible input parameters in the flow or process.

public class CountParams {

@InvocableVariable(required=true)

public Id contactId;

@InvocableVariable

public Boolean commitToDatabase;

}

Another thing to keep in mind is that any one class can only have one Invocable Method. If you want more utilities, you need to create more classes.

Verdict: So, Are Triggers Dead?

The short answer is: No.

Apex triggers run in any of 8 contexts – a combination of before or after an event (insert, update, delete, undelete). Declarative tools in Salesforce only run in two contexts: after insert, and after update. This means that declarative logic cannot be executed when a record is deleted or undeleted and cannot make changes to a record before it is committed to the database. That remains the domain of triggers.

For after insert and update logic, however, it is becoming clear that declarative tools are slowly gaining an advantage with the help of code. After all, wouldn’t it be great if an admin, rather than submitting change requests to you, could handle these things by her or himself?

Isn’t it great to have a platform that is increasingly accessible to all?

About Amnon Kruvi

Salesforce Architect and Development leader with a background in startup companies and consultancy specializing in Force.com, CRM, and an assortment of web and mobile technologies.

Amnon has excelled as the technical lead to execute and manage projects from the very beginning stages to public release, and on to large international contracts. His technical expertise allows Amnon to analyze customer requirements, design a solution, and follow it to completion – either in a managing or development capacity.

About 1218 Global

A worldwide leader in consulting innovation, 1218 Global and its family of professional consulting companies (Regents Consulting Group, Convectus Solutions, Axcero Global, and 1218 Global HR Solutions) were each founded with unique delivery capabilities. From systems implementations and upgrades to Managed Services (EMEA, APAC and USA), 1218 Global has developed a track record for measurably improving client productivity, effectiveness, and profitability.

Salesforce Sharing Concepts Every Admin Should Understand by Amnon Kruvi

One of the most common questions when it comes to any software that collects data is security and accessibility. In this new era of data protection, it has become more important than ever for system administrators to properly control who gets to see what data.

Perhaps you’ve decided that your marketing team should no longer have access to all of your customers’ purchase history; or that your North American division should stay out of APAC’s business. Maybe you are studying for your Certified Sharing and Visibility Designer exam (in which case, you deserve my sympathies for what you’re about to go through). Whatever it is, you’ve somehow gotten lost on the internet and found yourself reading this article.

Read more

“Old” and “Young” Workers – A Perspective

Jonathan Brostrom

Principal Consultant, 1218 Global – EMEA

jonathan.brostrom@1218global.com

Your Age. Such a simple enough entry on an application. Date of Birth. Age. A number that comes pre-loaded with conceptions, preconceptions, stereotypes, legal implications, attitudes, and story lines. It is the same with your photograph or in-person appearance. Age. What an interesting and unavoidable truth.

Read more

SuccessConnect 18: Innovation and Solution Management with SuccessFactors

Innovation

Denis Tournesac, Senior Vice-President, Global Head of General Business and Tak Kusano, Vice President, SuccessFactors presented how SAP is out-innovating the competition. Their focus is on Product and Engineering, Innovation and Extensibility through SAP’s partners and creating the foundation, best practices, and processes, to ensure SAP leverages their vibrant eco-system of great solutions.

Read more

Welcome to SAP SuccessConnect 2018: Insights from Las Vegas

SAP SuccessConnect 2018 got underway in Las Vegas this week with over 4,000 customers and 864 Partners in attendance, plus more than 4,000 people attending virtually. Greg Tomb, President SAP SuccessFactors opened the convention with insights into the market and how business is evolving. Stating early in his address, Greg noted “Customers have choice. If we don’t treat them with white glove service, it will not be a world-class experience.  All of us basically “say the same thing” to our customers but Strategy and Messaging are the keys to success.”

Read more

Employee Central Payroll: Making the Case for Multi-Country Implementors vs Local Payroll Vendors

This article explores the advantages of Employee Central Payroll (ECP) implementations utilizing proven Multi-Country service providers to enhance the employee experience and fully capitalize on Client HR investment. 1218 Global HR Solutions professionals have extensive Client-side work experience and multi-country expertise. This enables a better understanding of Client operational requirements and helps identify what features of an ECP system best address client needs.

Read more

The Client/Consultant Relationship: An Interview with Mark Crist, Part 1

This is the first in a three-part series of interviews with Mark Crist, Chief Delivery Officer, 1218 Global. The series explores the critically important client/consultant relationship and how to properly balance resources, maintain open communication, and deliver successful implementation and upgrade results.

Read more

The Client/Consultant Relationship: An Interview with Mark Crist, Part 2

This is the second in a three-part series of interviews with Mark Crist, Chief Delivery Officer, 1218 Global. The series explores the critically important client/consultant relationship and how to properly balance resources, maintain open communication, and deliver successful implementation and upgrade results.

Read more