5

I know it's possible to create a Process Builder that executes based on receiving a Platform Event but is it possible to use the Process Builder to simply create a new Record every time an event is received?

https://help.salesforce.com/articleView?id=process_start.htm&type=5

It seems as though I need to specify Matching Criteria for an existing record which is not something I want to do.

I simply want to map fields from the Platform Event to fields on a new custom object Record every time the event is received.

If I receive 50 events, I want to create 50 new records in my custom object.

(I know this can be done via Apex triggers I'm simply trying to avoid doing so for this use case)

2 Answers 2

3

From docs:

If the process starts when a platform event message is received, associate the process with a platform event and an object, and specify matching conditions. Because every process acts on a Salesforce record, it requires a single record as a starting point. That way, the criteria and actions know where to start evaluating and executing.The process fails if it finds:

1) Multiple records that match the criteria.

2) No records that match the criteria.

This bit is bit funny from SF end, But you can bypass it, but providing a dummy record.

Create a dummy Object, with an external field `D_External__c'. Then create a single record of that dummy Object. And set Value of External Field as constant. eg 78234564654

Now add an extra field in your event My_External_Dummy_Field__C , and default its value as 78234564654 . The one you defined in the record you created.

enter image description here

This will make sure, each event fired will have My_External_Dummy_Field__C as 78234564654

In your Process Builder, Match your Dummy_Object's external field with My_External_Dummy_Field__C

enter image description here

As this matching condition will always match because of single record of dummy object and setting the default value of the platform event, your process builder will always run. And you can create do whatever you want.

1
  • 2
    Thanks. I was afraid the dummy object solution was going to be the workaround. I was hoping I was just missing something obvious. Thanks for the responses!
    – Jamie G
    Mar 1, 2019 at 23:01
0

Here's a blog post with a video that talks about how to address this topic: https://unofficialsf.com/creating-a-custom-notification-flow-that-responds-to-a-platform-event/

The dummy object approach that Prasad describes is a valid way to get around the fact that Process Builder demands a Matching Condition even though there's not necessarily any connection between the platform event and SObjects.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .