function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JJamesJJames 

Creating notification messages through apex classes

Hi,

I am looking for a solution where I need to provide a notification to the user when a certain action takes place on a managed package apex page. I don't have access to the page itself as it is protected, but I need to create a notification to tell the user if a certain action took place.
The managed package allows apex code on the action but it returns a Map<string,string> with the page reference so I don't really have access to creating the page reference either, unless it is defined in the URL, because I can only pass the url not an object.

Is there a best practice or any solution that you can think of to generate a message to the user through the apex class? I can't use the error message because i still need the action to process, and when I addError it doesn't process the action.

Any help is much appreciated.
Thanks.
NagendraNagendra (Salesforce Developers) 
Hi James,

If this is lightning, and you can control the app, you could add a component to the utility bar of the app to display notifications, and/or call toast notifications. Then your apex code could communicate to the utility component via a platform event or something.

If their packaged page is global maybe you can wrap it inside your page and have an extra header for custom messages (<apex: iframe...). JavaScript may be necessary.

Other options... send them an email, insert a task record (in classic, they will see a popup), or insert a record and then alert them about it on a page you own that you know they will visit shortly thereafter.

It really depends on what the message needs to portray.

Thanks,
Nagendra