UI Builder - Link to destination

vidhya_mouli
Giga Sage

Is it possible to redirect to different pages from a simple list based on the link clicked. For example, it should take me to different pages based on whether I click Project and Developer. I am having a simple list page for Project and a card page for Developer.

 

vidhya_mouli_0-1727768616707.png

 

1 ACCEPTED SOLUTION

Kevin83
ServiceNow Employee
ServiceNow Employee

Got it perhaps you need a script like this, adapted to your exact use case

Screenshot 2024-10-03 at 8.52.22 AM.png

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
	const route  = event.payload.table === "sys_user" ? "user" : "task";

	return {
		route: route,
		fields: {
			sysId: event.payload.sys_id
		}
	};
}

 

View solution in original post

4 REPLIES 4

Kevin83
ServiceNow Employee
ServiceNow Employee

Yes, when the "Reference link clicked" event is triggered the payload for that event should be different for the links from different columns. That is the table and sys_id payload properties should be different.

I am aware of payload properties. I think I was not clear in my question. When I click on Project I want to go to a different page and when I click on Developer I want to go to a different page. Right now, I can only link to one single page when a reference link is clicked.

Kevin83
ServiceNow Employee
ServiceNow Employee

Got it perhaps you need a script like this, adapted to your exact use case

Screenshot 2024-10-03 at 8.52.22 AM.png

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
	const route  = event.payload.table === "sys_user" ? "user" : "task";

	return {
		route: route,
		fields: {
			sysId: event.payload.sys_id
		}
	};
}

 

vidhya_mouli
Giga Sage

Thank you, it worked.