4

In release Winter'21 was introduced new Target option for Custom Notifications (see here). I would like to have a specific Community page as Target Page Reference. Still, I can't figure out the format I need to put into the Target Page Reference attribute on Custom Notification action. Every format I try makes the flow fail with the error Invalid parameter value for: targetPageRef. I would like to navigate to the Community Home page. Any suggestion? enter image description here

3
  • 1
    I've had a similar issue and have tried the following: 1) a string with a partial URL, 2) An apex instance of a pagereference with the partial URL, 3) the getURL() method on that pagereference.
    – Bigears
    Oct 17, 2020 at 11:50
  • @Bigears did any of that work?
    – mascot
    Oct 20, 2020 at 12:08
  • 1
    No, it didn't. I was just adding my experience. Apologies for not being clearer. However, the answer below worked for me and I've been able to navigate as I need to pages within the community.
    – Bigears
    Oct 21, 2020 at 18:54

3 Answers 3

8

It seems that targetPageRef is expecting lightning pageReference types in a string format, so if you pass the otherwise json as a string, like the following:

"{"type": "standard__objectPage","attributes": {"objectApiName": "Task","actionName": "list"},"state":{"filterName":"Recent"}}"

you'll be redirected to the listview of the recent Task records when clicking the notification.

3
  • I would like to navigate to the community Home page. Do you have any suggestion on how to achieve that?
    – mascot
    Oct 20, 2020 at 12:10
  • 1
    @mascot to reference a community home, page the type comm__namedPage must be used, followed by the "Home" value in the name attribute. So the string "{"type": "comm__namedPage","attributes": {"name": "Home"}}" should cover your use case.
    – zigzig
    Oct 21, 2020 at 16:39
  • Hi @zigzig, I'm struggling to get this to work here salesforce.stackexchange.com/questions/331750/… via the new Apex API trying just the JSON string. Any thoughts?
    – Keith C
    Jan 20, 2021 at 11:21
2

Thanks to @Keith for answer here For redirecting in communities you can use the below code.

private final Map<String, Object> communityPageRef = new Map<String, Object>{
    'type' => 'comm__namedPage',
    'attributes' => new Map<String, Object>{
        'pageName' => 'home'
    }
};

customNotification.setTargetPageRef(JSON.serialize(communityPageRef));

If you are on a console tab in lightning and you want to navigate to home page then use this.

private final Map<String, Object> lightningPageRef = new Map<String, Object>{
    'type' => 'standard__namedPage',
    'attributes' => new Map<String, Object>{
        'pageName' => 'home'
    }
};
customNotification.setTargetPageRef(JSON.serialize(lightningPageRef));
0

Figured I'd add this as nobody online seem to say it regarding where you need to put that in flow. You can paste that code into a text template variable (make sure it's set as plain text), then use that variable in the send custom notification action under Target Page Reference.

You must log in to answer this question.

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