I have been doing a quite a bit of work lately with Lightning Process Builder. It has been very helpful in automating various business processes.
I had the need to kick things up a notch a dive into Invocable Methods as an immediate action in my flow. There are some great posts out there on Lightning Process Builder and Invocable Methods, if you want to learn more.
One of the features with the InvocableMethod annotation is the ability to add a label and description to your provide more context when in Process Builder.
For example, the following provides a more meaningful label in the Apex Action drop down in Process Builder
The label is displayed rather than just the class name.
Now here is where things started to break down for me. After building out a few separate Invocable Apex classes (each class can only have one Invocable Method), Process Builder started throwing an Error whenever I selected Apex as an Action Item. "Unfortunately, there was a problem" with Error ID (-2121053559)
I opened a support case with Salesforce, but didn't get very far. They said it was a null pointer exception, but that wasn't very helpful to me. So time to do some good old-fashioned sleuthing.
In once case, I had a invocable method and a non-invocable method of the same name in the same class. Perhaps this was the cause? Changing the non-invocable method yielded the same results.
Then it hit me. For one class, I was not sure of the label yet and put in an empty string as a place holder.
I had the need to kick things up a notch a dive into Invocable Methods as an immediate action in my flow. There are some great posts out there on Lightning Process Builder and Invocable Methods, if you want to learn more.
One of the features with the InvocableMethod annotation is the ability to add a label and description to your provide more context when in Process Builder.
For example, the following provides a more meaningful label in the Apex Action drop down in Process Builder
public class ChargePaymentPost { @InvocableMethod ( label='Posts a Charge Payment to a Journal Entry' description='Takes a Charge Payment application and posts ' +
'the appropriate GL Accounts') public static void PostChargePayment(ListchargePaymentIds){ } }
The label is displayed rather than just the class name.
Now here is where things started to break down for me. After building out a few separate Invocable Apex classes (each class can only have one Invocable Method), Process Builder started throwing an Error whenever I selected Apex as an Action Item. "Unfortunately, there was a problem" with Error ID (-2121053559)
I opened a support case with Salesforce, but didn't get very far. They said it was a null pointer exception, but that wasn't very helpful to me. So time to do some good old-fashioned sleuthing.
In once case, I had a invocable method and a non-invocable method of the same name in the same class. Perhaps this was the cause? Changing the non-invocable method yielded the same results.
Then it hit me. For one class, I was not sure of the label yet and put in an empty string as a place holder.
public class PaymentPost { @InvocableMethod ( label='' description='') public static void PostPayment(ListpaymentIds){ } }
Sure enough, the empty string crashed Process Builder. Adding a label fixed my problem. When you decide to dive into Invocable Apex, be sure to either set the label or omit it entirely to avoid the issue I encountered.
UPDATE (18-May-2016): This has been confirmed as an issue by Salesforce and will be fixed in an upcoming patch. You can following the known issue for updates.
No comments:
Post a Comment