cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Fiori Elements DataFieldWithURL in separate window

former_member435529
Participant
0 Likes
6,382

Hello,

I am using annotations DataFieldWithURL and the link is open up in the same window.

How can it be open in a separate window ?

Thanks,

Javier

Accepted Solutions (0)

Answers (5)

Answers (5)

monokizsolt7
Participant

I solved it by adding this to my Component.js:

$('body').on('click', 'a', (e) => e.target.target = '_blank');

Shiv_602
Discoverer
0 Likes
Thank you, It's working for me.
rahullohia
Product and Topic Expert
Product and Topic Expert

Hello,

The annotation 'datefieldwithurl' doesnt have an inbuilt property to force a new browser page. There are two ways you can achieve this.

1. If using annotations, return the 'url' like this-> |javascript:void( window.open('| && |{ url }| && |') )|

adding the javascript function to the final url will force the browser to open a new page.

2. If not using annotation, add an 'onclick' or 'onpress' event and then use 'sap.m.URLHelper.redirect(url, true)' in the handler

Thanks,

Rahul

former_member435529
Participant

Thanks for your inputs, Rahul.

I finally used annotations but attached link operation to that field.

former_member738409
Discoverer
0 Likes

Hi Rahul,

I used first method working as expected! Thank you!

smritigupta
Explorer
0 Likes

Hello Rahul, @rahullohia

I have a list card in overview page, where in i have some quicklinks for the apps. I want to open the app in new tab upon clicking the link. I tried the code with the annotation , however it didn't work. This is how my annotation looks like:

<Record Type="UI.DataFieldWithUrl">
                            <PropertyValue Property="Url" Path="URL"/>
                            <PropertyValue Property="Value" String = "Description"/>
</Record>
Could you please suggest how it should be added to Path?
 
Thanks,
Smriti Gupta
former_member435529
Participant
0 Likes

Gopal,

Please add attachPress to your field ID. This will make your field clickable. You can find this ID in Elements tab in Developer Tools.

Attach a function from where you can launch the URL in a separate window: yourField.attachPress(this.yourNewFunction).

I added the above in the onInit method of the Extension Controller.

Hope this helps.

Javier

gopalmishra673
Explorer
0 Likes

Thanks Javier, Its was helpful.

vinod_snair
Product and Topic Expert
Product and Topic Expert
0 Likes

Hello Javier,

Good to know that you found a solution.

I kindly request you to provide a feedback to Fiori guideline with details of your use case so they consider the same in future.

Regards,

Vinod

vinod_snair
Product and Topic Expert
Product and Topic Expert
0 Likes

Hello Javier,

DataFieldWithUrl as per the UI Vocabulary doesn't offer this capability. That is also aligned with the Fiori design principles for navigation. You can take a look at the design principal here. The introduction section itself describe the following

Navigation in SAP Fiori follows standard navigation paradigms of various web applications. When a user navigates to a new screen, the user’s system default navigation is in place. Depending on individual browser settings and functionality, new screens can also be opened in a new tab or window by using a long tap or right-click (using a mouse)

Hope this answers why do you see this annotation capability. I would strongly recommend you to keep your application aligned to the Fiori design guideline so that end users have a consistent user experience through out.

Regards,

Vinod

former_member435529
Participant
0 Likes

Thank you Vinod. I finally found a workaround by creating Link

gregorw
SAP Mentor
SAP Mentor
0 Likes

Hi Vinod,

should I consider it as a bug and file an incident if the right-click -> Open in new tab option doesn't work with DataFieldWithUrl?

Best Regards
Gregor