Solved

How do I delete a row using UDB library?

  • 15 April 2021
  • 7 replies
  • 150 views

  • Anonymous
  • 0 replies

In a WebDesigner script I try this (in a js function):

 

$.udb('PERS').executeQuery()
        .then(function() {
            $.udb('PERS').rows('condition', { PERSON_ID: "="+event.detail }).rowDelete({



                check: function(){



                 alert('Deleted: ' + event.detail);



                 return true;



                }



            });
        })
        .catch(function() {
            console.log("Something went wrong deleting a person!");
        });

where event.detail is the correct id of the person, I console logged it out.

No error, even the alert with Deleted comes but no actual delete is performed.

I tried instead of 

$.udb('PERS').rows('condition', { PERSON_ID: "="+event.detail }).rowDelete


this:

 

$.udb('PERS').rows({ PERSON_ID: event.detail }).rowDelete

but still does not work

icon

Best answer by Patrick Camphuijsen 16 April 2021, 13:21

View original

7 replies

Userlevel 2
Badge +1

I can reproduce this in usd10beta2, it seemingly deletes a row, but after a page refresh the record is still there. Maybe @Patrick Camphuijsen  has a clue?

 

 

related articles:

 

Yes, let us see if @Patrick Camphuijsen can help, hopefully.

Did you try

$.udb.commit();

afterwards?

Just executing the .rowDelete() function does not commit the delete manipulation by itself.

OMG, I have to say the UDB old docs didn’t mentioned the state of these kind of transactions, when u must commit yourself or not, let me try it ;)

@Patrick Camphuijsen :

$.udb('PERS').executeQuery()
        .then(function() {
            $.udb('PERS').rows('condition', { PERSON_ID: "="+event.detail }).rowDelete({

                check: function(){

                 $.udb.commit();
                 alert('Deleted: ' + event.detail);

                 return true;

                },
                error: function(){
                 alert('error');
                }

            });
        })
        .catch(function() {
            console.log("Something went wrong deleting a person!");
        });

still not working...

@adrian.albu :

 

You should not call the commit action from the check function (which is executed before the delete action is considered), but afterwards, e.g. like this:

 

$.udb('PERS').executeQuery()
.then(function() {
$.udb('PERS').rows('condition', { PERSON_ID: "="+event.detail }).rowDelete({
check: function(){
alert('Deleted: ' + event.detail);
return true;
}
})
.then(function() {
$.udb.commit();
})
.catch(function(){
alert('error');
});
})
.catch(function() {
console.log("Something went wrong deleting a person!");
});

 

@Patrick Camphuijsen it worked this way!!

But honestly looking at the docs about it :

https://developer.usoft.com/documentation/100doc/_rowdelete.htm

there is not a full practical example there and from the explanation I didn’t get it that will not delete the row since it says if the check function returns true WILL be deleted :)

 

Thanks!

Reply