UI Builder: Link to Destination Sys_id from Data Resource

edgarbasto
Tera Expert

Hello.

 

I'm developing a Portal Experience within UI Builder and I have a Repeater component that will show a brief info of some catalog items and have 2 stylized texts and a button to link to the portal. Both text components get the info from @item.value....

But when it comes to the button event handler, I need to link to an external url. I don't know how to grab the sys_id that comes from the data resource within the code.

I would like to have something like this:

 

function evaluateEvent({api, event}) {
	return {
		route: null,
		fields: null,
		params: null,
		redirect: null,
		passiveNavigation: null,
		title: null,
		multiInstField: null,
		targetRoute: null,
		external: {
			url: "/esc?id=sc_cat_item&sys_id=" + @item.value.sys_id.value
		}
	};
}

 

Is this possible or there is a better way to do this ?

 

I know I could also have a Text Link component but I would prefer to have the buttons.

1 ACCEPTED SOLUTION

Nootan Bhat
Kilo Sage

Hi @edgarbasto,

Best way is to use the debugger in your script. And open browser console. Once you have clicked on button, it will show all the event and api data.

 

to access item object use the api:

 

return {
		route: null,
		fields: null,
		params: null,
		redirect: null,
		passiveNavigation: null,
		title: null,
		multiInstField: null,
		targetRoute: null,
		external: {
			url: `esc?id=sc_cat_item&sys_id=${api.item.value._row_data.uniqueValue}`
		}

 

Let me know if it helped.

 

Thanks

Nootan

  

View solution in original post

2 REPLIES 2

Nootan Bhat
Kilo Sage

Hi @edgarbasto,

Best way is to use the debugger in your script. And open browser console. Once you have clicked on button, it will show all the event and api data.

 

to access item object use the api:

 

return {
		route: null,
		fields: null,
		params: null,
		redirect: null,
		passiveNavigation: null,
		title: null,
		multiInstField: null,
		targetRoute: null,
		external: {
			url: `esc?id=sc_cat_item&sys_id=${api.item.value._row_data.uniqueValue}`
		}

 

Let me know if it helped.

 

Thanks

Nootan

  

Didn't know about the 

debugger;

 

Thank you. This helped a lot and fixed it.

 

Best regards,