You can use this function to navigate to other menu items using JavaScript.
This function is available for all visible component types, but on NewEdit pages you would usually prefer menuItemPopup or setFieldValuesFromWebService instead.
You first need to create a menu item link of type JavaScript link and give it an alias. You can then call Api.followLink
with that alias and an optional set of arguments to go to the target menu item.
Do keep in mind that a malicious user can also call this function. You can not assume that arguments your link gets from JavaScript have not been tampered with.
Api.followLink('myalias');
Api.followLink('myalias', { first: 'abc', second: 'def' });
If all you need is a clickable HTML-element then you do not need to call Api.followLink
directly: you can use the data-api-link
and data-api-link-arg-xxx
attributes instead.
<a data-api-link="mylink" data-api-link-arg-first="abc" data-api-link-arg-second="def">...
Creates a link that, when clicked, will call
Api.followLink('mylink', {
first: 'abc',
second: 'def'
})
Alias of the JavaScript link to follow. If no link with the given alias exists on the page or if the user does not have permission to open the target menu item then a warning will be logged to the browser's console.
An optional object with values that the link can reference using the JavaScript argument type.