Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Process records in a row Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Process records in a row

Unread post by toms »

Hi,

I would like to edit records one after the other without going back to the browse form every time.

The workflow should work like this:

1. Fetch the next record (from a table, where a done_flag is not set. e.g. SELECT * FROM customers WHERE cust_done_done is null LIMIT 1;
2. The user inputs data in the edit form/updates some fields
3. The user saves the record (a js/php script would set a 'done' flag/datetime stamp. I know how to do that. Eg. Set cust_done_done = 1 or set it to now())
4. A next record is fetched (basically the same as in step 1)
5. The record is opened in the edit form

Now I'm not sure if there is an inbuilt way to open "any" next record that meets a criteria ( cust_done_done is null)

Looking at nuForm(), I can only pass a specific row id or open the browse form

Code: Select all

nuForm(nuGetProperty('form_id'), r, '', '', '0', '1');
Any advice would be greatly appreciated,
next_record.png
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Process records in a row

Unread post by admin »

toms,

I have changed nuReturnNewRecord() to optionally take a primary key as a parameter.

So you'll need the latest from Github.

http://wiki.nubuilder.net/nubuilderfort ... nNewRecord

That way you can return to any record you wish.

(in the example below, it will bring up payments that are due and not paid - if you set a record to Paid and save, it will return the next Outstanding payment that is due)


So in After Save it would look like this...

Code: Select all


$today  = Date('Y-m-d');
$s      = "
            SELECT payment_id 
            FROM `payment` WHERE pay_due <= '$today' AND pay_paid = 'Outstanding'
            ORDER BY pay_due
        ";

$t      = nuRunQuery($s);
$r      = db_fetch_row($t)[0];

if(db_num_rows($t)== 0){           //-- new record if no criteria met.
   nuReturnNewRecord();
}else{
   nuReturnNewRecord($r);
}


next_primary_key.PNG
Hopefully, I have understood your question.


Steven
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Process records in a row

Unread post by toms »

Steven,

Nice, it works just as I expected! Thanks a lot for the quick implementation!
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Process records in a row

Unread post by admin »

.
Post Reply