cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with sap.m.dialog

Former Member
0 Kudos

Hi UI5 Developers,

Kindly help me out in this use case.

I have a table in its toolbar I have placed 2 buttons. On the first button, I open a dialog box with three text fields, and on submit the three values are getting stored in a model. Once I close the dialog and open it again I am getting duplicate ID error for the textfields. And also I should add the second time values also to same session. Kindly share your ideas to solve it out.

Table with two buttons

Adding data to dialog box

Values got entered into table through JSON format

Selecting the Add button again, below error is displayed. (packagest is id of first textfield in dialog box)

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Rheema,

Try -


var oDialog = new sap.m.Dialog("packagest",{

               afterClose: function(){

               oDialog.destroy();

               }});

(or)


var oDialog = sap.ui.getCore().byId("packagest");

if(!oDialog){

     //create your dialog control here

}

Regards,

Sai Vellanki.

Former Member
0 Kudos

Thanks Sai. Your first method works out.

Answers (1)

Answers (1)

SergioG_TX
Active Contributor
0 Kudos

HI Rheema, please create the dialog in your view, not in the event of your controller. also, make sure you have a unique id in each control. once you create the dialog in the view, then in your controller open event, you may do the open function.. or close function.. this ensures you create it only once and you interact with the dialog via events