Page 1 of 1

Access subform entries over hash cookies

Posted: Fri Jun 28, 2019 9:46 am
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.

Re: Access subform entries over hash cookies

Posted: Fri Jun 28, 2019 10:49 am
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.

Re: Access subform entries over hash cookies

Posted: Fri Jun 28, 2019 2:14 pm
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');

Re: Access subform entries over hash cookies

Posted: Thu Jul 04, 2019 1:44 am
by admin
fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven

Re: Access subform entries over hash cookies

Posted: Fri Jul 05, 2019 9:33 am
by fpdragon
admin wrote:fpdragon,

Try using #RECORD_ID# instead of #sub_index_key#.


Steven

Thank you. That was the solution.

Re: Access subform entries over hash cookies

Posted: Sat Jul 06, 2019 4:40 am
by admin
.