setTargetPageRef in Custom Notification in Salesforce

setTargetPageRef in Custom Notification in Salesforce

Sample Code:

String pgRef = '{ type: "standard__recordPage",attributes:{recordId:' +  objAcc.Id + ',objectApiName: "Account",actionName: "view"} }';
notification.setTargetPageRef( pgRef );

In the above code, it redirects the user to the Account Record Page based the Account Id from objAcc.Id variable.

For additional PageReference types, check the below link

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_page_reference_type

Leave a Reply