- 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-12-2022 04:09 PM
What do you mean by "I'm trying to use a script in the "Link to destination" event handler". Are you trying to achieve that when user clicks on a KB article, it should show the article itself and not a list view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2022 04:18 PM
I have a table shown in the Simple List component. I have references fields on the table. Most of them open fine with the 'record' route. But instead of the standard KB article record, I want it to show the 'kb_view' route when the reference in that column is clicked instead of 'record'.

- 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 09:40 AM
Thanks Brad, that did it.
The route is 'kb_view' this is a demo instance that's been upgraded for about 4 releases, so perhaps that's new change in San Diego.
It appears that you have to do a cache.do after each modification/save of the script as well. Anything I should do to submit this defect?
I also modified targetRoute: 'current' to open in sub tab and it's working great.
Thanks,
Aaron