Use Business Events
In Nimble AMS Spring '19 release, we introduced Business Events and included 9 stock business events for your association to immediately begin using.
For this current release, Business Events can NOT be created without errors. It is recommended to use the nine Standard Events of the Business Events feature to ensure the feature processes properly during the beta timeline. Please wait for the Summer '19 release to take advantage of this feature.
Stock Business Events
Here are the 11 business events you can begin to use:
Business Event Label | Business Event (API) Name | Object | Event Type | Trigger | Description/Logic |
---|---|---|---|---|---|
Community User Created | CommunityUserCreated | User | EngagementEvent | DML | Evaluates whether a user is a newly created community user, based on UserType. Uses the CommunityUserCreatedEvaluation class. |
Member Drop | MemberDrop | Membership__c | EngagementEvent | DML | EndDate__c != null && EndDateOverride__c != null && EndDateOverride__c < EndDate__c |
Member Join | MemberJoin | Membership__c | EngagementEvent | DML | Evaluates if a member is joining for the first time, based on the membership's stage (Join means it's a new member). Uses the MemberJoinEvaluation class. |
Membership Lapsed | MemberLapse | Account | EngagementEvent | Time Based | Evaluates if a membership has lapsed today. As with all time-based business events, it is evaluated as part of a nightly job. When the account's Lapsed On date field matches today's date, this business event fires. |
Membership Reinstated | MembershipReinstated | Account | EngagementEvent | DML | Evaluates if a membership has been reinstated, which fires if the account's Join On date is updated to be after their Lapsed On date. Uses the MembershipReinstatedEvaluation class. |
Membership Type Changed | MembershipTypeChanged | Account | EngagementEvent | DML | Evaluates if a member's type was A (and A is not null) and has changed to B. Uses the MembershipTypeChangedEvaluation class. |
Order Fully Upserted | OrderFullyUpserted | Order__c | TransactionEvent | Custom | A lot happens in the system when an order is inserted or updated. This fires at the very end of the entire cart submission process, after everything else (memberships, registrations, etc.) have been successfully created/updated. Using this is an elegant way to have a process do something after an order is created or edited. |
Order Paid in Full | OrderPaidInFull | Order__c | TransactionEvent | DML | Evaluates if an order had a balance and is now paid in full (i.e., the Balance is now $0.) Uses the OrderPaidInFullEvaluation class. |
Payment Applied to Order Item | PaymentAppliedToOrderItem | PaymentLine__c | TransactionEvent | DML | Evaluates if payment line is an insert and not an update. Uses the PaymentAppliedToOrderItemEvaluation class. |
Membership Cancelled | MembershipCancelled | Account | EngagementEvent | DML | Evaluates if a membership has been cancelled. Uses the MembershipCancelledEvaluation class. |
Membership Order Item Cancellation | MembershipOrderItemCancellation | Order__c | TransactionEvent | DML | Evaluates if a membership has been cancelled, by verifying if the Record Type of Order Item is It is recommended for the first time users of the Business Events to subscribe to the upgraded type of business event i.e.; Membership Order Item Cancellation. |
What are Platform Events?
The "Platform Event" is the larger category that each business event falls within, and when creating a process you'll need to select one before seeing the available business events for that platform event.
The platform events are:
- Engagement Event: Any activity-based occurrence in the system, such as a community user getting created, a membership lapsing, or a registration being canceled.
- Transaction Event: Any financial-based occurrence in the system, such as an order being processed, or an order balance becoming $0.
What are the Triggers?
Triggers specify if the business event was a data change, a time change, or something else:
- DML: Stands for Data Manipulation Language, and includes triggers like record creation, updates, or deletes. DML can reference an
Evaluation
directly on the business event, or it can reference anEvaluation Apex Class
. - Time Based: Includes any date/time based triggers. With this option, a date/time field on the object is referenced and a nightly job fires when the value in that field has elapsed.
- Custom: Reserved for complex criteria that is custom built.
Use Business Events
Business events are always used in the context of Process Builder. So you'll need permission to manage Process Builder, and you should also have a solid understanding of using Process Builder before proceeding. Learn more about Process Builder in this Trailhead trail: Automate Simple Business Processes with Process Builder.
Let's create a new process that posts to Chatter when an order is created/updated.
- Go to Setup | Process Builder.
- Click New.
Add a
Process Name
. ForThe process starts when
, selectA platform event occurs
.Click the Add Trigger box, and set up the trigger as follows:
Select the
Platform Event
that corresponds with the business event you want to use (see table above). In this example, it'sTransactionEvent
.Select the
Object
that corresponds with the name of the business event you want to use (see table above). In this example, it'sOrder
.Be sure to select the Nimble AMS Order object (NU__Order__c), not the stock Order object from the Salesforce platform. The Process Builder interface doesn't distinguish the two unfortunately, so you should select one and then click the
Field
dropdown to make sure you selected the correct object.- For
Matching Conditions
, we need to establish what links our platform event to the record we want to interact with. In this case, it's the business event:In
Field
, select the record ID for the object. In this example, it'sRecord ID
.Be sure to select the correct ID field. You'll know you picked the true record ID field if the
Type
picklist changes toID
. For example, the Account object has a text field namedAccount Id
, which will not work. For the Order object, its Name field is calledOrder Id
, which is also incorrect. You can quickly identify the wrong field because selecting one will change theType
picklist to something other thanID
, such asString
.- For
Operator
, selectEquals
. - For
Type
, selectEvent Reference
. - For
Value
, selectRecord Id
.
Click Save to finish adding the trigger.
- Click the Add Criteria diamond, and set up the criteria as follows:
- Enter a
Criteria Name
that helps identify what the trigger is. A name based off of the business event generally makes sense. For example:Order is Fully Upserted
. - For
Criteria for Executing Actions
, selectConditions are met
. For
Set Conditions
:Field Value Source
Platform event
Field
Business Event
Operator
Equals
Type
String
Value
OrderFullyUpserted
(This value depends on the business event you want to use as the trigger. Be sure to enter the business event's API Name, not its label. The API Name can be found in the table at the top of this page. For custom business events, the API Name can be found in Setup | Custom Metadata Types | Manage Records for Business Events).- For
Conditions
, leave it asAll of the conditions are met (AND)
. Click Save.
- Enter a
- Lastly, create actions, which can reference the order that fired the business event. For example, let's post to Chatter and reference the order name. Under Immediate Actions, click Add Action:
- For
Action Type
, selectPost to Chatter
. - Provide an
Action Name
such asPost Order to Chatter
. - For
Post to
, determine which Chatter feed to post to, such asThis Record
. - When you click
Merge Field
, notice how you can reference the order's fields and any related objects, just as you can with non-platform-event-based processes. Add some fields and a message. - Click Save.
- For
You can then activate this process and test to ensure that a Chatter post is created when an order is successfully created or edited.
By walking through this example, you should be able to see just how powerful business events are. You were able to bypass building complex logic or a large formula in the criteria diamond, and jump right to the actions you want to have happen when an order is created or edited!