Hi,
I would like to retrieve the customer_id of the current record I have just saved.
Can I retrieve it in the nuAfterSave() fonction. Or do I have to use another function to retrieve this value.
It is to update the related link in the parent record.
Thx for confirming this approach .
Yves
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Retriever the customer_id value after having save Topic is solved
-
- nuBuilder Team
- Posts: 4291
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: Retrieve the customer_id value after having save
yes it's the primary key, the one that links records between 2 tables.
I have a parent form company in which I have inside ent_customer_id. I have a button on it which opens a pop-up custom form.
Behind the pop UP button I have the following code
And in the customer form behind customer code, I thought update ent_customer_id on the onAfterSave() function.
Is it a correct approach ? Do I have to use the hash cookie via nuSetProperty instead ?
Many thx,
Yves
I have a parent form company in which I have inside ent_customer_id. I have a button on it which opens a pop-up custom form.
Behind the pop UP button I have the following code
Code: Select all
If (!(nuGetValue('ent_customer_id')){
nuPopup ('my_id_of_customer_form','-1','');
} else { nuPopup ('my_id_of_customer_form',nuGetValue('ent_customer_id'),'');}
Code: Select all
parent.nuSetValue('ent_customer_id',nuGetValue('customer_id')
Many thx,
Yves
-
- nuBuilder Team
- Posts: 4291
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: Retriever the customer_id value after having save
When I add a console.log to check the value of customer_id in the onAfterSave() event, it returns null. if you look the content of the database the primary key has been successfully updated. It seems like the primary key isn't available at that point. Which event should I use to capture this information required to link records together ?
Is this the right approach, or am I missing something? It feels like there should be a standard method for this, as linking records by opening a popup of a child form from the main form seems like a common task.
What is the best practice for handling this kind of functionality ?
Maybe use of hash cookie RECORD_ID instead of motif_id ?
Thanks in advance!
Yves
Is this the right approach, or am I missing something? It feels like there should be a standard method for this, as linking records by opening a popup of a child form from the main form seems like a common task.
What is the best practice for handling this kind of functionality ?
Maybe use of hash cookie RECORD_ID instead of motif_id ?
Thanks in advance!
Yves
-
- nuBuilder Team
- Posts: 4291
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: Retriever the customer_id value after having save
thx again !!! How could I know that without you ? I would be helpful to add this function to the documentation.
Yves
PS : I have created a procedure to retrieve the primary key from the database ; Useless with this nuRecordId() function !!!
Yves
PS : I have created a procedure to retrieve the primary key from the database ; Useless with this nuRecordId() function !!!