The Winter '21 CustomNotification Class offers two ways to set the target navigated to when the message displayed under the "bell" icon is clicked:
setTargetId(Id targetId)
- Sets the target record of the custom notificationsetTargetPageRef(String pageRef)
- Sets the target page of the custom notification
What can the pageRef
string contain? I'd like to use these notifications in a community (i.e. the bell notifications) where the page to go to would need to be set via that value. So far no value I have set results in the notification appearing; the notification does appear when the targetId
is set.
PS
Based on Shamina's comment/link I tried passing this JSON (without the line feeds; this is one of the LWC PageReference Types) using API 50 and got:
Invalid parameter value for: targetPageRef
for:
{
"state":{
"eventId":"a053F000004MTJOQA4"
},
"attributes":{
"name":"event-details"
},
"type":"comm__namedPage"
}
I also can't get this to work with e.g. the standard__webPage
type either. But see Jeferson's answer where some of the standard__*
types work.
What am I missing here? Are only some PageReference types supported?
PPS
Can this be set by any means e.g. via a flow or the REST API? I tried the REST API approach, and got:
Unexpected data type for targetPageRef: expected String
with JSON data for the targetPageRef
and:
Invalid parameter value for: targetPageRef
with JSON data serialized to a string for the targetPageRef
.
Note that the "Send Custom Notifications" permission must be granted to avoid this error:
Unsupported action type: CUSTOM_NOTIFICATION_ACTION
c__
prefix.JSONGenerator
but nothing works insetTargetPageRef
from anonymous apex.