Skip to main content

A) Insert Button into Page list.

Name the button as “update_all_to_approve“.

  • In tab – “Client Before” clear all text.
  • In tab – “Server” add this code:

//—–STATUS CHANGE TO APPROVE WHEN CLICK BUTTON————
global $dal;
while ( $data = $button->getNextSelectedRecord() ) {
// set “recordStatus” field to ‘Approved’
$sql = “Update project set recordStatus=’Approved’ where id=”.$data[“id”];
CustomQuery($sql);
}

  • 3. In tab – “Client After” add this code:

//—-After update to Approve, page will reload——-
pageObj.reload({a:’reload’});


B) Go to Tab Event > Table Name > List Page > JavaScript OnLoad event

add this code
//—————-TO ACTIVE OR NOT ACTIVE THE CUSTOM BUTTON BY SELECTED DATA———————-
var selectedRecords = pageObj.getSelectedRecords();
pageObj.getItemButton(‘update_all_to_approve’).addClass(‘disabled’);
$(‘input[name=”selection[]”], input[id^=chooseAll]’).change(function()
{
selectedRecords = pageObj.getSelectedRecords();
if( selectedRecords.length > 0 )
{
pageObj.getItemButton(‘update_all_project_to_approve’).removeClass(‘disabled’);
}
else
{
pageObj.getItemButton(‘update_all_project_to_approve’).addClass(‘disabled’);
}
})