0

In community builder I have set up a navigation menu, and I know in Aura I can fetch those items using navigationMenuBase and via JS have it navigate to those pages selected. I'm wondering if there is a way to get or generate the URL of the items directly?

Essentially, I'm trying to get around the fact that because you don't have valid href's for the template, the user is not able to right-click and open in a new tab (tab opens but is blank because the anchor link is not valid). I know in LWC you can generate Url with a page reference, but the v.menuItems data that the aura component receives does not provide that information. Can the menuItems response be used at all to get the url data from SF? Or is there another method or variable navigationMenuBase provides that can be used?

Example response from v.menuItems: {id: 1, label: 'Case Management', active: false}

2
  • from this documentation developer.salesforce.com/docs/component-library/bundle/… you can pass the id from menuItems and call the javascript component.getSuper().navigate(id);
    – hendra
    Commented Nov 16, 2022 at 7:48
  • That navigates to the link, yes, but it does not provide the href to put into the html. We are currently doing this, but we also need the href it evaluates to to place in the html to provide a valid Href on the anchor tag.
    – babyYoda
    Commented Nov 16, 2022 at 17:01

1 Answer 1

0

For the purpose of building a custom menu, but based on standard one, I was using connect API from frontend directly:

export async function retrieveNavMenuItems(url,communityId,navigationLinkSetDeveloperName,addHomeMenuItem,sessionId) {
    let endPoint = `${url}/services/data/v50.0/connect/communities/${communityId}/navigation-menu/navigation-menu-items?navigationLinkSetDeveloperName=${navigationLinkSetDeveloperName}&includeImageUrl=true&addHomeMenuItem=${addHomeMenuItem}&publishStatus=Live`;
    let response = await fetch(endPoint, {
        method: "GET",
        headers: {
            'Authorization': `Bearer ${sessionId}`
        }
    })
    let parsedResponse = await response.json();
    return parsedResponse;
}

This will return something like this:

{
    "menuItems": [
        {
            "actionType": "InternalLink",
            "actionValue": "/settings/XXXXXXX",
            "imageUrl": null,
            "label": "MenuItemZ",
            "subMenu": [],
            "target": "CurrentWindow"
        },
        {
            "actionType": "InternalLink",
            "actionValue": "/account/XXXXXXXX",
            "imageUrl": null,
            "label": "MenuItemY",
            "subMenu": [],
            "target": "CurrentWindow"
        },
        {
            "actionType": "InternalLink",
            "actionValue": "/membership",
            "imageUrl": null,
            "label": "MenuItemX",
            "subMenu": [],
            "target": "CurrentWindow"
        }
    ]
}

Hope this helps you to build your custom menu.

More Info: https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_responses_navigation_menu_item.htm

You must log in to answer this question.

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