UIB Link to destination
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2024 05:15 AM
Hello,
I'm looking for a way to script a "link to destination" action(in a list component), so that it points to a page in our service-now instance, but is not part of the "experience". The current problems I'm facing are:
- I cannot point to an external url when using a scripted handler. Instead I get a "Page doesn't exist".
- I cannot access the current instance name inside the script, so that I can build the proper url. I tried using the window object, but it is not defined even though that the script seems to be executed on the client, since my console.log works.
The reason I'm using a script is that we need to create a dynamic url, but don't want to use an "experience" page.
Example code:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({
api,
event
}) {
if (event.payload.table && event.payload.table === 'incident') {
return {
route: `https://www.google.com`,
fields: null,
params: null,
redirect: null,
passiveNavigation: null,
title: null,
multiInstField: null,
targetRoute: null,
external: true,
navigationOptions: null
};
}
return {
route: null,
fields: null,
params: null,
redirect: null,
passiveNavigation: null,
title: null,
multiInstField: null,
targetRoute: null,
external: null,
navigationOptions: null
};
}
Instance version: Vancouver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2024 08:05 AM
Hi @Dimitar Vutov ,
Could you please go through this article? I hope it will help you.
Link : https://www.servicenow.com/community/developer-forum/get-instance-url-via-ui-builder/m-p/2735950/pag...
Please mark my answer helpful and correct.
Regards,
Subhashis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2024 07:38 AM
Hi! Thank you for you answer, I totally overlooked the data resources as a means to 'deliver' the instance name. Thank you! However this only solves half of my issue, since I still have to redirect dynamically outside of the "experience" and currently I can't do that with a scripted action handler. Any ideas are welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2024 12:47 AM
Hello Dimitar,
this might be a very late response but I had a similar requirement as you recently and this is the solution I found.
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({
api,
event
}) {
const payload = event.payload;
const sys_id = payload.row.sys_id.value;
const table = payload.table;
return {
route: null,
fields: null,
params: null,
redirect: null,
passiveNavigation: null,
title: null,
multiInstField: null,
targetRoute: null,
external: {
url: "/now/nav/ui/classic/params/target/" + table + ".do%3Fsys_id%3D" + sys_id
}
};
}
this code lets you open a record in platform view from a workspace list component (instead of opening another tab in the workspace).
I've found that it's not necessary to specify the instance name in the url section as it wil insert it automatically (in my case at least).
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2025 08:15 AM
THIS IS WHAT I'VE BEEN LOOKING FOR!!!! THANK YOU NicoD1!!! Is there documentation anywhere to explain this return object? I'd love to be able to manipulate it more in the future