Page 2 of 2

Re: Subform with many to many relationship

Posted: Tue Jul 14, 2020 7:09 pm
by treed
Hum, this page of the wiki https://wiki.nubuilder.cloud/ ... hp/Objects says hash cookies are good in run object filters and RecordID's. How does one see what hash cookies are available and their values?

In the video you linked there is an edit button for the contact. How does that work???

Re: Subform with many to many relationship

Posted: Tue Jul 14, 2020 8:39 pm
by Janusz
How does one see what hash cookies are available and their values?
In PHP and SQL these hash cookies are always available.
https://wiki.nubuilder.cloud/ ... sh_Cookies

You can can define any value in JS to be available as hash cookie in PHP and SQL:
https://wiki.nubuilder.cloud/ ... etProperty

just real example:
in JS

Code: Select all

nuSetProperty('ZLEC_TO_FREEZE',$('#par_zlecenie').val());
nuRunPHPHidden('SUB_FREEZE','z');   //'z' is not important just any string value should be placed here
and in PHP procedure "SUB_FREEZE" you can read these data

Code: Select all

....
$pz=('#ZLEC_TO_FREEZE#');
...
$q="UPDATE parts SET par_sub_frozen='1', par_updated_by = '$r',par_updated_on = '$timestamp' WHERE par_zlecenie='$pz';";
...
The list of hash cookies for specific form can be obtained inside PHP with:
https://wiki.nubuilder.cloud/ ... PHP#nuHash

in a quick way you can display the value on the form using display object placing in the sql for example:

Code: Select all

Select '#USER_ID#'
In JS you can get form properties from JS code or console (F12) with:
https://wiki.nubuilder.cloud/ ... Properties

Re: Subform with many to many relationship

Posted: Tue Jul 14, 2020 9:13 pm
by Janusz
In the video you linked there is an edit button for the contact. How does that work???
Edit button (with onclick) or the "ATTM - File name" display field (with onfocus) makes exactly the same thing so starting with the basic code of display field:

Code: Select all

if (nuFORM.edited) {return;}  var f=nuSubformValue(this, 'con_rap'); if (f!=='') {nuForm('5d5fbf488ceedd4',f,'','');}
Do nothing if form is during edit:

Code: Select all

if (nuFORM.edited) {return;} 
read the current record ID of the "contact" table / the line from the subform on which you clicked / so in this case it reads the lookup value and this value is in fact ID of the contact table to that specific record.

Code: Select all

var f=nuSubformValue(this, 'con_rap');
next if value is not empty - it open the contact form in edit form on which only this specific record is displayed.

Code: Select all

if (f!=='') {nuForm('5d5fbf488ceedd4',f,'','');}
the value from example 5d5fbf488ceedd4 is the Contact Form ID - you can get this value with nuCurrentProperties() - but make sure that the proper form is focused in the browser - especially if you use the run/iframes.
https://wiki.nubuilder.cloud/ ... ipt#nuForm
Przechwytywanie.JPG
For the edit button I added the hide and show option to avoid double click on the button - double click can force to execute the code twice - so I always protect all buttons from double click. You can do it with hide/show or disable/enable.