Page 1 of 1

Cannot introduce a subform to a fast form

Posted: Wed Jan 05, 2022 6:32 pm
by Scrolin
I've been following the pizza delivery tutorial in the NuBuilder wiki (https://wiki.nubuilder.cloud/ ... y_Tutorial) to learn how to use NuBuilder, but have been unable to define the invoice fast form.It objects to the Subform object with the error message "Invalid Field Name item_sf".
Leaving the subform field name blank gives error "The Field Names must be both unique and not blank"
Using the primary key invoice_id gives error "The Primary Key invoice_id must not be entered"
Whilst using the inv_number field name also gives error "The Field Names must be both unique and not blank"

The field name validation on the form builder screen is clearly not being suspended for subform objects (or have I missed something?)

The version.txt file holds the following
nuBuilder Forte 4.5

DB Version: V.4.5-2021.12.26.00
Files Version: V.4.5-2021.12.26.00

(V.MajorVersion-CurrentDate.BuildNumber)

Re: Cannot introduce a subform to a fast form

Posted: Wed Jan 05, 2022 6:36 pm
by kev1n
Hi,

Could you upload a screenshot of the Fast Form filled in where we can see the issue? Thanks

Re: Cannot introduce a subform to a fast form

Posted: Wed Jan 05, 2022 7:26 pm
by Scrolin
Not sure it gives you any better clue, but here goes
Image

Re: Cannot introduce a subform to a fast form

Posted: Wed Jan 05, 2022 7:40 pm
by kev1n
If you create a form for an existing table, you can't add field names that don't exist in the table.
Not being familiar with that tutorial, normally the item_sf column should have been added when the table was created.
Now all you can do is to manually add the item_sf column in the DB (using e.g. phpMyAdmin) or run this SQL:

Code: Select all

ALTER TABLE `invoice` ADD `item_sf` VARCHAR(25) NULL DEFAULT NULL AFTER `inv_gand_total`;
Afterwards, you will probably have to log in to nuBuilder again.

Re: Cannot introduce a subform to a fast form

Posted: Thu Jan 06, 2022 6:10 pm
by Scrolin
Surely this is a bug. Whilst adding an (unused) column to the table is a valid workaround it does not solve the issue permanently.

Having done some debugging and tracing I believe the fix is to modify the function nuFFInvalidColumns as defined whithin zzzzsys_form.sfo_javascript where zzzzsys_form_id = 'nufflaunch' as follows

Code: Select all

function nuFFInvalidColumns() {
    let msg ='';
    let table = nuGetValue('fastform_table');
    if (nuFORM.getTables().indexOf(table) == -1) return '';
    let sf = nuSubformObject('obj_sf');
    for (let i = 0; i < sf.rows.length; i++) {
        /* start of Scrolin mod */
        let rowtype=sf.rows[i][3];
        if (rowtype=='nu59e44658a0c7724')  {  /* object type is Subform (see table zzzzsys_object) */
           continue;
        }
        /* end of Scrolin mod */
        let field = sf.rows[i][2];
        let exists = nuFORM.tableSchema[table].names.indexOf(field);
        if (sf.deleted[i] != 1 && exists == -1) {
            msg += nuTranslate('Invalid Field Name') + ' <b>' + field + '</b>'
        }
    }
    return msg;
}
This is offered in the hope of being helpful and of course requires verification/authorisation from the nuBuilder coders

Re: Cannot introduce a subform to a fast form

Posted: Fri Jan 07, 2022 12:16 pm
by kev1n
Thanks Scrolin, for your suggestion. The change must be carefully tested and possible use cases considered.

Re: Cannot introduce a subform to a fast form

Posted: Sun Jan 09, 2022 4:17 pm
by kev1n
Scrolin, I have now taken a closer look at it and modified nuFFInvalidColumns() so that fields / columns (such as 'Word', 'Subform', 'Image', 'HTML', 'Button') are permitted which do not exist in the table but whose values ​​are not saved in the table either.

Re: Cannot introduce a subform to a fast form

Posted: Sun Jan 09, 2022 5:19 pm
by Scrolin
Thanks Kevin, is that in the current downloadable release yet?

Re: Cannot introduce a subform to a fast form

Posted: Sun Jan 09, 2022 5:41 pm
by kev1n
Yes, it's on Github