1

Can anyone please give a brief idea how to implement below scenario?

We have a batch class which runs every 1 hour where we are making callout and getting data from 3rd Party System and updating opportunity object. Once successfully updated all the opportunity records in salesforce, we need to send Custom notification to the opportunity owner(user). The notification body should contain template stored in Custom Label/ metadata with dynamic data updated into the opportunity object.

Below is the screenshot for showing notification to user enter image description here

0

You can follow the below mentioned steps which can help you send the custom notifications to the opportunity owner(s):

  1. Make API calls and on successful operation, update the opportunity and custom setting
  2. After updating the custom setting, fire an platform event
  3. Write a process builder and subscribe for the platform event which you are firing from the apex on successful execution of API calls
  4. From the process builder, send the custom notification using the custom setting stored (follow these steps https://developer.salesforce.com/blogs/2019/06/get-buildspiration-with-custom-notifications-in-summer-19.html)

Let me know if you face any difficulty in achieving the same.

  • We can't do DML on metadata in apex, it will give error "DML operation Update not allowed on", and we can't get custom metadata reference in process builder for Notification – Chetan Nandre Sep 5 at 8:21
  • You can create a field on opportunity and update that which can be used further. Why you want to go with custom metadata only. – Shahroz Beig Sep 5 at 8:23
  • As a admin, he can change title and body in future. So we need to keep configurable template stored somewhere like metadata or custom setting. – Chetan Nandre Sep 5 at 8:26
  • You can use custom setting then. upsert is allowed on CS via name. – Shahroz Beig Sep 5 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.