cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate ID error while navigating back in SAP UI5

narinderpal
Explorer
0 Kudos

Hello Experts,

I have created a simple application where there are two UI5 views. Each view contains one button, which navigates to the other view.

Means, on first view, if i click on the button, it navigates to the second view and on the second view if i click, it should take me back to the first view.

From first view, it is taking me to the second view, however while navigating back, it is giving me error "Uncaught Error: Error: adding element with duplicate id 'container-Navigation_Test---View1'".

Please note I have not created any other component and not given id to any component.

Accepted Solutions (1)

Accepted Solutions (1)

mariusobert
Developer Advocate
Developer Advocate

It'd hard to tell you the exact issue as I don't know your code. Most likely the root cause it that the UI5 controls are being recreated when you navigate back (instead of reusing the already created controls).

You control definition probably specifies a fixed ID which causes this error. A quick and dirty fix would be to remove the fixed IDs. The correct way to fix it would be to find out why the controls are being recreated and try to avoid this behavior (as it also has a negative impact on the loading time of you app)

cschaefer2
Explorer
0 Kudos

As I keep getting this same "duplicate id error" over and over again, and I am not even sure I understood your answer correctly (concerning removal of "fixed ids"), could you maybe point us to some reading material where the whole issue is explained in more depth? (I am aware of openSAP classes and https://ui5.sap.com documentation... unfortunately I still don't get it.) Thank you.

mariusobert
Developer Advocate
Developer Advocate

They are also referred to as "stable IDs". Maybe you know them under this name https://sapui5.hana.ondemand.com/#/topic/f51dbb78e7d5448e838cdc04bdf65403

Answers (0)