Welcome to the nuBuilder Forums!

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

How to Call the Record ID of a Subform Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
cjuliao
Posts: 13
Joined: Fri Mar 23, 2012 2:58 am
Has thanked: 1 time
Been thanked: 1 time

How to Call the Record ID of a Subform

Unread post 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
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: How to Call the Record ID of a Subform

Unread post 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
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
cjuliao
Posts: 13
Joined: Fri Mar 23, 2012 2:58 am
Has thanked: 1 time
Been thanked: 1 time

Re: How to Call the Record ID of a Subform

Unread post by cjuliao »

ImageThank 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
You do not have the required permissions to view the files attached to this post.
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: How to Call the Record ID of a Subform

Unread post by steven »

cjuliao,

Can you upload of copy of your db (without any private information), and we can take a look.


Steven
A short post is a good post.
nc07
Posts: 118
Joined: Tue Jun 04, 2019 4:05 am
Has thanked: 5 times
Been thanked: 22 times

Re: How to Call the Record ID of a Subform

Unread post by nc07 »

cjuliao wrote: Wed Dec 18, 2024 5:42 pm ImageThank 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
cjuliao
Posts: 13
Joined: Fri Mar 23, 2012 2:58 am
Has thanked: 1 time
Been thanked: 1 time

Re: How to Call the Record ID of a Subform

Unread post by cjuliao »

Good night Steven

He sent you the database.

Please review the Download button and the SHOWFILE_CON_TEC procedure
You do not have the required permissions to view the files attached to this post.
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: How to Call the Record ID of a Subform

Unread post 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
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
cjuliao
Posts: 13
Joined: Fri Mar 23, 2012 2:58 am
Has thanked: 1 time
Been thanked: 1 time

Re: How to Call the Record ID of a Subform

Unread post 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.
Post Reply