Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

global hash cookie

Questions related to customising nuBuilder Forte with JavaScript or PHP.
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

global hash cookie

Unread post 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
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

Re: global hash cookie

Unread post by BDemeuse »

see attached
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: global hash cookie

Unread post 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) ?
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

Re: global hash cookie

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: global hash cookie

Unread post 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.
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

Re: global hash cookie

Unread post 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.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: global hash cookie

Unread post 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);
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

Re: global hash cookie

Unread post by BDemeuse »

It sounds fine :-) I will try and let you know.
BDemeuse
Posts: 92
Joined: Mon Apr 12, 2021 3:09 pm
Has thanked: 1 time
Been thanked: 2 times

Re: global hash cookie

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: global hash cookie

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