Before Delete on subform

Questions related to customising nuBuilder Forte with JavaScript or PHP.

Before Delete on subform

Unread postby chpwebmaster » Wed Apr 21, 2021 2:48 am

Is there a way I'm missing or can it be added to have a Before Delete event on a subform I tried a
Code: Select all
nuDebug('Deleting');
on the main forms Before Delete and got noting when I deleted a subform row what I want to end up with is a way to run a check on one of the subform rows and log to another table if the row was a late charge.
chpwebmaster
 
Posts: 27
Joined: Tue Jun 11, 2019 12:30 am
nuBuilder Version: 4.5

Re: Before Delete on subform

Unread postby kev1n » Wed Apr 21, 2021 3:47 am

Use the BS event to retrieve that information.

Use

Code: Select all
nuDebug(nuHash());


to see the form's data structure.
kev1n
nuBuilder Team
 
Posts: 2057
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Before Delete on subform

Unread postby chpwebmaster » Tue May 18, 2021 9:39 pm

Solved

Code: Select all
$rows = nuSubformObject('FormName')->rows;

foreach($rows as $key => $row){
    if($row[5] == 'Late Charge' && $row[10] == 1){ // Col 5 is the nuHash col with my charge Method and 10 is the one tracking the delete state
        // Logging LC Removal to History
        $q  = "INSERT INTO `tblEventLog` (`EventID`, `AssocBillingID`, `Action`, `ActionDate`) VALUES (NULL, '#BillingID#', 'LateChargeRemoved', CURRENT_TIMESTAMP);";
        nuRunQuery($q);
    }
}
Last edited by kev1n on Tue May 18, 2021 9:50 pm, edited 1 time in total.
Reason: Added Code tags.
chpwebmaster
 
Posts: 27
Joined: Tue Jun 11, 2019 12:30 am
nuBuilder Version: 4.5


Return to Custom Code

Who is online

Users browsing this forum: No registered users and 7 guests