Page 1 of 2
global hash cookie
Posted: Wed Feb 23, 2022 4:12 pm
by BDemeuse
Hi,
I thought to have a good understanding of global hash cookie but no

In my case (see attach), I have a B&E form and in the edit from an another B&E form launched in a iframe via a run object.
Ideally, I should had created a subform instead of a run/iframe but I have a join and then edition does not work.
Anyway, I have got the "record_id" (in the hash()) till the BE step but I need it for saving he new record and then of course, it is not the "parent record_id" but the current.
I have tried the nuSetProperty( 'id', record_id.value, true) as you have suggested previously in the JS of the custom code of the form and it does not work

So, shortly, how can I get the record_id (hash) I have in the BE step to the BS or AS step ?
Thanks a lot in advance
Re: global hash cookie
Posted: Wed Feb 23, 2022 4:13 pm
by BDemeuse
see attached
Re: global hash cookie
Posted: Wed Feb 23, 2022 4:32 pm
by kev1n
I'm not sure I understand everything.
Where and how do you want to use the hash cookie id when setting nuSetProperty( 'id', record_id.value, true) ?
Re: global hash cookie
Posted: Wed Feb 23, 2022 6:24 pm
by BDemeuse
Sorry ... you are lost with all details.
I just want to keep the "record_id" (=1457, id of the "Liste Edit contacts") I have got in the hash() of the BE step in the AS step (record_id = -1 ... of course is a new record to add to the "Relations AssociƩes".
In attachment the debug entries of the different steps.
Thanks a lot
Bri
Re: global hash cookie
Posted: Wed Feb 23, 2022 8:44 pm
by kev1n
RECORD_ID (not record_id) contains the record id in AS.
You are setting a Hash Cookie with the value record_id.value. Is record_id an object on your form or do you want to retrieve the current record id? Then retrieve it nuCurrentProperties().record_id.
I'm still not 100% sure what you are trying to do. If you'd like to change the PK of a saved record, then you can only do that in the AS event by running an update query on the db.
Re: global hash cookie
Posted: Thu Feb 24, 2022 9:05 am
by BDemeuse
I will try to explain the use case.
I have a table with the contact data (tr_contact) and I need a table (tr_relation) with the relation between contacts.
I have tried to recreate a subform with a FK but I have a join (to replace the id of the contacts by the names) but with the join I cannot edit and save the data.
So, I have created a Browse and Edit form with a run/iframe in the edit form of the tr_contact.
When I edit the relation, in the BE, I have got the "record_id of parent contact(1457)" but I lost it after the edition (-1) as then the record_id is the new record_id of the tr_relation.
What I see as solution, is to save the record_id of the tr_contact before editing the tr_relation to use it when I have the record.
I hope my explanations are now better

Thanks a lot.
Re: global hash cookie
Posted: Thu Feb 24, 2022 9:23 am
by kev1n
How about storing the record id in BE in a global hk and then, in AS, retrieve it and modify the record's pk by running an Update query?
Code: Select all
nuAddToHashCookies('parent_record_id', nuHash()["record_id"], true);
Re: global hash cookie
Posted: Thu Feb 24, 2022 9:39 am
by BDemeuse
It sounds fine

I will try and let you know.
Re: global hash cookie
Posted: Thu Feb 24, 2022 11:43 am
by BDemeuse
It does not work:" call to undefined function"
Is it a version issue ?
My current version is
nuBuilder Forte 4.5
DB Version: V.4.5-2021.04.27.00
Files Version: V.4.5-2021.04.26.02
(V.MajorVersion-CurrentDate.BuildNumber)
Thanks
Thanks
Re: global hash cookie
Posted: Thu Feb 24, 2022 11:47 am
by kev1n
Yes, that function was only added sometime later. You'll need to update nuBuilder or you could try incorporating
it into nucommon.php