Page 1 of 1
How to Call the Record ID of a Subform
Posted: Tue Dec 17, 2024 1:54 am
by cjuliao
Good evening everyone
With nubuilder 3.0 it referred to the id code of the records in a form
get record from db using parameter passed through runIt() via a hash id
$sql ="SELECT * FROM requerimiento where tarea_id='#runIt1#'";
nuDebug($sql);
Que comando o variable replaces #runlt# in nubuilder forte 4.5?
I appreciate the guidance
Re: How to Call the Record ID of a Subform
Posted: Tue Dec 17, 2024 5:06 am
by steven
Hi cjuliao,
I can't remenber, but I think nuBuilder 3 may have required a where clause.
eg.
Code: Select all
SELECT * FROM zzzsys_object WHERE sob_zzzsys_form_id = '#RECORD_ID#'
(I'm not sure about
#runIt1#)
But nuBuilder 4 does it automatically by asking for the Foriegn Key...
fk.png
I think you are refering to
#RECORD_ID#. - now refered to as a
Hash Cookie...
https://wiki.nubuilder.cloud/index.php? ... sh_Cookies
You can still use Hash Cookies in the Subform's SQL.
You can check the Hash Cookies available in PHP by using
nuHash()...
https://wiki.nubuilder.cloud/index.php?title=PHP#nuHash
You can create your own as well in JavaScript with
nuSetProperty()...
https://wiki.nubuilder.cloud/index.php? ... etProperty
Steven
Re: How to Call the Record ID of a Subform
Posted: Wed Dec 18, 2024 5:42 pm
by cjuliao
![Image]()
Thank you very much Steven for the attention, but I have not been able to solve it.
When I click the download button of the subform, I need the value of the ID of the subform record to call me.
The procedure for the consultation is:
$select = "SELECT tarea_id, concep_tecnico_file_name, concep_tecnico_file_type, concep_tecnico FROM requerimiento WHERE tarea_id = ?";
$stmt = nuRunQuery($select, ['#?????????? #']);
If I use #RECORD_ID" it returns the form code 153eb96eaced14
And I need you to return the registration code of subform 15aa80171121cb.
What should I use for the statement $stmt = nuRunQuery($select, ['#?????????? #']);
See attached image of the form Imagen_1.png
Thank you steven for the attention, nubuilder helps me a lot to an environmental management program
Imagen_1.png
Re: How to Call the Record ID of a Subform
Posted: Wed Dec 18, 2024 7:43 pm
by steven
cjuliao,
Can you upload of copy of your db (without any private information), and we can take a look.
Steven
Re: How to Call the Record ID of a Subform
Posted: Wed Dec 18, 2024 11:48 pm
by nc07
cjuliao wrote: ↑Wed Dec 18, 2024 5:42 pm
![Image]()
Thank you very much Steven for the attention, but I have not been able to solve it.
When I click the download button of the subform, I need the value of the ID of the subform record to call me.
The procedure for the consultation is:
$select = "SELECT tarea_id, concep_tecnico_file_name, concep_tecnico_file_type, concep_tecnico FROM requerimiento WHERE tarea_id = ?";
$stmt = nuRunQuery($select, ['#?????????? #']);
If I use #RECORD_ID" it returns the form code 153eb96eaced14
And I need you to return the registration code of subform 15aa80171121cb.
What should I use for the statement $stmt = nuRunQuery($select, ['#?????????? #']);
See attached image of the form Imagen_1.png
Thank you steven for the attention, nubuilder helps me a lot to an environmental management programImagen_1.png
Hi may be you can do something like this on the onclick event of the button;
Code: Select all
var id = event.target.parentNode.id;
var subformid = $('#' + String(id)).attr('data-nu-primary-key');
if (subformid === '-1' || subformid === ''){
alert('can not update this record');
return } else{
nuSetProperty('subformid', subformid);
nuPopup('60e788e61c8c475', subformid, '','');
}
Modify as needed, once you retrieve you subformid you can use
Code: Select all
nuSetProperty('subformid', subformid);
and retrieve it as hash #subformid# in the sql. Just a work around. hope this helps.
Regards
Nilesh
Re: How to Call the Record ID of a Subform
Posted: Thu Dec 19, 2024 4:08 am
by cjuliao
Good night Steven
He sent you the database.
Please review the Download button and the SHOWFILE_CON_TEC procedure
Re: How to Call the Record ID of a Subform
Posted: Thu Dec 19, 2024 9:10 pm
by steven
Hi cjuliao,
Add this JavaScript...
Code: Select all
nuSetProperty('CURRENT_SUBFORM_ID', $(this).parent().attr('data-nu-primary-key'),1);
nuRunPHP('SHOWFILE_CON_TEC', '', 1);
Here...
nuJS.png
And change the PHP in your Procedure to this...
Code: Select all
nuDebug(nuHash());
$select = "SELECT tarea_id,concep_tecnico_file_name,concep_tecnico_file_type,concep_tecnico FROM requerimiento WHERE tarea_id = ?";
$stmt = nuRunQuery($select, ['#CURRENT_SUBFORM_ID#']);
if ($stmt->rowCount() > 0) {
while($row = db_fetch_array($stmt)){
$nombre_archivo = $row['concep_tecnico_file_name'];
$documento_id = $row['tarea_id'];
$fileData = $row['concep_tecnico'];
$fileType = $row['concep_tecnico_file_type'];
$fileName = $row['concep_tecnico_file_name'];
$nombre_archivoreal = $row['concep_tecnico_file_name'];
header("Content-Type: $fileType");
header("Content-Disposition: attachment; filename=\"$fileName\"");
header("Content-Length: " . strlen($fileData));
echo $fileData;
}
}
If you open up Debug (after it has run)...
nuDebug.png
You can see that running nuHash() will show that
CURRENT_SUBFORM_ID has been created by the JavaScript above...
nuHash.png
Steven
Re: How to Call the Record ID of a Subform
Posted: Fri Dec 20, 2024 10:10 pm
by cjuliao
Good evening, Steven
Thank you very much for the assistance or help.
I want to thank you and congratulate you for this project, it is really a good tool that has helped me a lot in my work.
I'm sure I haven't taken advantage of nubuilder's full potential.
I wonder if there is a commercial version with permanent assistance.
This is because I would like to make use of the tool with a formal business relationship.
I speak Spanish and use a translator, so excuse me if I write something incorrectly.
The NC07 version also worked but latest code is a bit better.