Access subform entries over hash cookies

Questions related to customising nuBuilder Forte with Javascript or PHP.

Access subform entries over hash cookies

Postby fpdragon » Fri Jun 28, 2019 5:16 pm

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.
fpdragon
 
Posts: 23
Joined: Wed May 29, 2019 10:20 pm

Re: Access subform entries over hash cookies

Postby Janusz » Fri Jun 28, 2019 6:19 pm

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.
Janusz
 
Posts: 179
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Access subform entries over hash cookies

Postby Janusz » Fri Jun 28, 2019 9:44 pm

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');
Janusz
 
Posts: 179
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Access subform entries over hash cookies

Postby admin » Thu Jul 04, 2019 9:14 am

fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven
admin
Site Admin
 
Posts: 3081
Joined: Mon Jun 15, 2009 9:53 am

Re: Access subform entries over hash cookies

Postby fpdragon » Fri Jul 05, 2019 5:03 pm

admin wrote:fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven



Thank you. That was the solution.
fpdragon
 
Posts: 23
Joined: Wed May 29, 2019 10:20 pm

Re: Access subform entries over hash cookies

Postby admin » Sat Jul 06, 2019 12:10 pm

.
admin
Site Admin
 
Posts: 3081
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code