Skip to Content
author's profile photo Former Member
Former Member

Dialog Screen is working on first time but not at all time.

Hello expert,

While I'm developing my project I add a button which is calling a dialog screen but on first time its working perfect. But If I want to press the button one more time there is a error like this: "Uncaught Error: The object with ID pddepLayout1 was destroyed and cannot be used anymore."

Please help this situation.

Here is my all code :

var opddepButton1 = new sap.m.Button('opddepButton1',{text:'Ekle',



  function openDialog() {
    var opddepButton = new sap.m.Button('opddepButton',{text:'Ekle',press:function(){
            var fname = sap.ui.getCore().byId('pdmalkod').getValue();
            var lname = sap.ui.getCore().byId('pdparti').getValue();
            var aname = sap.ui.getCore().byId('pdmiktar').getValue();
            var bname = sap.ui.getCore().byId('pdolcbir').getValue();
            var cname = sap.ui.getCore().byId('pdmasyer').getValue();
            var dname = sap.ui.getCore().byId('pdnedekod').getValue();
            mdData.clients.push({"id":fname,"parti":lname,"miktar":aname,"olcbirimi":bname,"masyeri":cname,"nedkodu":dname });

    var labelidmalkod = new sap.m.Label('labelidmalkod',{text:'Malzeme Kodu:'
        var pdmalkod = new sap.m.Input('pdmalkod',{
       var labelidparti = new sap.m.Label('labelidparti',{text:'Parti:'
       var pdparti = new sap.m.Input('pdparti',{
       var labelidmiktar = new sap.m.Label('labelidmiktar',{text:'Miktar:'
      var pdmiktar = new sap.m.Input('pdmiktar',{
      var labelidolcbir = new sap.m.Label('labelidolcbir',{text:'Ölçü Birimi:'
     var pdolcbir = new sap.m.Input('pdolcbir',{
     var labelidmasyer = new sap.m.Label('labelidmasyer',{text:'Masraf Yeri:'
    var pdmasyer = new sap.m.Input('pdmasyer',{
    var labelidnedkod = new sap.m.Label('labelidnedkod',{text:'Neden Kodu:'
    var pdnedekod = new sap.m.Input('pdnedekod',{
     pddepLayout1.createRow(labelidmalkod, pdmalkod);
     pddepLayout1.createRow(labelidparti, pdparti);
     pddepLayout1.createRow(labelidmiktar, pdmiktar);
     pddepLayout1.createRow(labelidolcbir, pdolcbir);
     pddepLayout1.createRow(labelidmasyer, pdmasyer);
     pddepLayout1.createRow(labelidnedkod, pdnedekod);


Ogulcan G.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 16, 2015 at 01:44 PM

    Hi Ogulcan,

    I guess pddepLayout1 is a Matrix Layout. You are adding this layout to a dialog content.

    Instead of destroying content, why don't you use .removeAllRows() method of Matrix Layout. Something like this -

     function openDialog() {  
           var oLayout = sap.ui.getCore().byId("pddepLayout1");          //Get Hold of Matrix Layout
        oLayout.removeAllRows();               //Remove all Rows of Matrix Layout
        //and then your code


    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 16, 2015 at 07:20 AM

    Hi Ogulcan,

    I think it´s because you "destroy the content" (line 12 in your code snippet) of the dialog when open it. At first time pddepLayout1 is not part of the content. So it works. After first call pddepLayout1 is part of the content as you added it in line 89. So it will be destroyed and afterwards you can´t use it anymore. So I don´t know what´s the best approach in your case but maybe you should consider only destroying the content of pddepLayout1 and not the content of the complete dialog.

    Best regards,


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sebastian,

      Yeah I agree with you but I still couldn't fix my problem even try change where defination of pddepLayout1 and also change type of layout (for ex. border). I'm trying also right now another solutions but doesnt work for me.

      Thank you for answering,

      Ogulcan G.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.