Mass Deletion

Questions related to using nuBuilder Forte.

Mass Deletion

Postby redmonk » Mon Mar 12, 2018 9:46 pm

Any pointers on how to add Browse Action Button that can delete all selected records (based on search)
Posts: 11
Joined: Sun Feb 04, 2018 3:48 pm

Re: Mass Deletion

Postby toms » Tue Mar 13, 2018 10:05 pm

Something like this could work:

Set a Hash Cookie like:
Code: Select all
nuSetProperty('browsesql', nuCurrentProperties().browse_sql);

Use nuRunPHPHidden() to run a PHP procedure.

This PHP Procedure would then run a query to retrieve the primary keys of the (filtered rows)
Code: Select all
$s = "#browsesql#";
$t = nuRunQuery($s);

Next, you would have to build a delete statement to delete all rows that match these primary keys.

I know it may be a bit abstract, but it should work that way.

Re: Mass Deletion

Postby admin » Wed Mar 14, 2018 11:54 am


You could give this a go.

Add this to the Javascript of the Form...
Code: Select all

nuAddActionButton('deleteGroup', 'Delete Unfiltered Records', 'deleteWhere()');

function deleteWhere(){

    if (confirm("Are you sure you want to delete all unfiltered records?")){
        nuSetProperty('deleteFiltered', '1');
        nuSetProperty('deleteFiltered', '0');

And add this to Before Browse...
Code: Select all

if(nuHash()['deleteFiltered'] == '1'){
    $sql    = nuHash()['browse_sql'];
    $w      = strpos($sql, 'WHERE');
    $o      = strpos($sql, 'ORDER BY');
    $o      = !$o ? 10000 : $o;
    $s      = substr($sql, $w, $o - $w);
    $s      = str_replace('\\', '', $s);

    nuRunQuery('DELETE FROM theteblename ' . $s);


Site Admin
Posts: 3035
Joined: Mon Jun 15, 2009 9:53 am

Return to General