Welcome to the nuBuilder Forums!

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

Access subform entries over hash cookies

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
fpdragon
Posts: 38
Joined: Wed May 29, 2019 2:50 pm

Access subform entries over hash cookies

Unread post by fpdragon »

Hello,

I have the following structure:

Code: Select all

mainTable
mainTable.main_index_key
mainTable.data

subformTable
subformTable.sub_index_key
subformTable.main_index_key_link
subformTable.any_sub_data_1
subformTable.any_sub_data_2
Now I wanted to add a nuBuilder object to format and concat some data on subform level.
So I created:
subformTable.test_concat (as nuBuilder object, not in sql)
I took the following configuration:
Type "Display"
Access "Readonly"
Display SQL

Code: Select all

SELECT CONCAT(subformTable.any_sub_data_1, ' - ', subformTable.any_sub_data_2) AS test_concat FROM subformTable
This concats and displays the first entry of subformTable but the rest of the lines also get the first entry as expected.

Now I wanted to extend the SQL with a WHERE statement and hash cookies to display the current line.
I thought of something like this:

Code: Select all

SELECT CONCAT(subformTable.any_sub_data_1, ' - ', subformTable.any_sub_data_2) AS test_concat FROM subformTable WHERE subformTable.sub_index_key = '#sub_index_key#'
This does not work and I found out that the problem is the hash cookie is not resolved by nubuilder.
In the end it seems that none of the subformTable.* can be accessed as hash cookie.
Otherwise, mainTable.* can be accessed as hash cookie but this does not help.

Any idea? Thank you.
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Access subform entries over hash cookies

Unread post by Janusz »

Hi,
Please find enclosed working example from my DB.

Code: Select all

SELECT his_request,his_num_sztuki,hist_location,his_info,his_created_on,his_removed,
Format(TIMESTAMPDIFF(second,his_created_on,his_removed)/3600,1) AS his_diff
FROM historia_view WHERE his_request='#req_number#'
I thing the where statement is quite similar to your code.

In my case the req_number is the field name on the edit form. And from that form I am launching with a buton the report and based on the req_number field value I have required report.
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Access subform entries over hash cookies

Unread post by Janusz »

and if you are on the subfrom you can copy specific subform value to a temp field on the main form and later run report
(input / buton / onclick) with code similar as belowe and use '#temp_x#' in 'FR0_req' (instead of '#req_number#')
I did not fully test it but should work.

Code: Select all

var a=nuSubformValue(this, 'req_number'); 
$('#temp_x').val(a).change();
nuRunReport('FR0_req');
If you like nuBuilder, please leave a review on SourceForge
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Access subform entries over hash cookies

Unread post by admin »

fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven
fpdragon
Posts: 38
Joined: Wed May 29, 2019 2:50 pm

Re: Access subform entries over hash cookies

Unread post by fpdragon »

admin wrote:fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven

Thank you. That was the solution.
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Access subform entries over hash cookies

Unread post by admin »

.
Post Reply