
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2022 03:54 PM
I'm trying to use a script in the "Link to destination" event handler.
Use case is I want a referenced knowledge article to link out using the 'kb_view' page route instead of the 'record' routing. Linking from a Simple List.
I tried hardcoding the route and field paramaters, and I couldn't get the script to link out. If I fallback to the form, then I can use either 'record' or 'kb_view', but can't make it conditional.
I've also tried using the event.payload.params.table instead of event.payload.table and that didn't work either.
function evaluateEvent({api, event}) {
var routeSelect = '';
if (event.payload.table == 'kb_knowledge') {
routeSelect = 'kb_view';
} else {
routeSelect = 'record';
}
return {
route: routeSelect,
fields: {
'table': event.payload.table,
'sysId': event.payload.sys_id
},
params: null,
redirect: null,
passiveNavigation: null,
title: null,
multiInstField: null,
targetRoute: null,
external: null
};
}
Thanks for any assistance. -Aaron
Solved! Go to Solution.
- Labels:
-
Now Experience UI Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2022 08:52 AM
Hi Aaron,
A couple of things here. The first is that I'm sure you know the names of your routes, but when I spin up a new workspace the default route name for the kb page is actually 'kb' rather than 'kb_view' so I would double check that to make sure.
The bigger issue is that it appears there may be a defect in San Diego around scripting the link to destination event handler where it doesn't work while using the form view does work. There is a workaround, which is to run a cache.do on your instance. I was able to replicate both this error (using your script with kb instead of kb_view) and then it worked after I cleared the cache on that instance.
Just a quick disclaimer that clearing the cache is something you want to be careful about, especially in production instances as the instance will run a little slower for a bit.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2022 11:04 AM
I do think the dev team knows about it, but you could open an incident and see if there's an existing problem where you could get notified about the fix if you want to.