Hello,
is there a way to open a new record from a another edit form (of another object) but to handover the current record ID and use it to prefill a lookup object in the new record?
e.g.:
I want to open a new TASK in the edit form of an existing PROJECT.
The RECORD_ID of the current project should be used to prefill the lookup object in the new TASK.
BR,
Oli
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.
Handover RECORD_ID to another form
-
- Posts: 115
- Joined: Tue Dec 12, 2017 11:28 pm
- Location: Aberdeen, UK
- Has thanked: 9 times
- Been thanked: 12 times
Re: Handover RECORD_ID to another form
Hi oli,
You can use nuSetProperty to set a hash cookie value that will persist for the duration of the session. This means it can be set on one form and then picked put later on another form. You need to use the optional third parameter, set to true e.g.
This will create the hash cookie #MY_ID# using the ID of the record. This can then be used later in the WHERE clause of the SQL code for the lookup browse form.
I hope this helps.
Neil
You can use nuSetProperty to set a hash cookie value that will persist for the duration of the session. This means it can be set on one form and then picked put later on another form. You need to use the optional third parameter, set to true e.g.
Code: Select all
nuSetProperty("MY_ID",nuCurrentProperties().record_id,true);
I hope this helps.
Neil
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Handover RECORD_ID to another form
Another possibility is to use session storage (Example here)
And then use nuGetLookupId to populate the Lookup Object with that Primary Key.
And then use nuGetLookupId to populate the Lookup Object with that Primary Key.
Re: Handover RECORD_ID to another form
I still have an issue with handing over an id and it would be great if somebody can help me.
I set a hash cookie in a run object that is opening a new EDIT Form where I want to set the Customer ID in a lookup object with following Custom Code on the RUN object:
On the target form (where the customer ID should be used to set the value in the lookup object for Customers) I can see the correct ID with PHP:
On the target form I used following custom code to set the ID in the lookup object (ite_customer):
But it seems the hash cookie can't be used in the JAVA Script.
It looks like there is no value.
I tried it with: but I don't get any value for var fk.
Any ideas what's wrong here?
I set a hash cookie in a run object that is opening a new EDIT Form where I want to set the Customer ID in a lookup object with following Custom Code on the RUN object:
Code: Select all
var cus = $("#pro_customer").val();
nuSetProperty("CUST_ID", cus, true);
Code: Select all
nuDebug("#CUST_ID#");
Code: Select all
var fk = $("#CUST_ID").val();
nuGetLookupId(fk, 'ite_customer'); // Write ID to Lookup for Customer
It looks like there is no value.
I tried it with:
Code: Select all
nuMessage(['Customer = ', fk]);
Any ideas what's wrong here?
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Handover RECORD_ID to another form
I tried it with following code but it didn't work too.
1st Form to get the customer id (Custom code on run object):
target form to set value in lookup object "ite_customer":
var fk is still empty.
1st Form to get the customer id (Custom code on run object):
Code: Select all
var cus = $("#pro_customer").val();
sessionStorage.setItem('PK_B',nuCurrentProperties().cus);
Code: Select all
var fk = sessionStorage.getItem('PK_B'); // Retrieve the PK of Table A
sessionStorage.removeItem('PK_B'); // Remove the item from session storage
nuGetLookupId(fk, 'ite_customer'); // Write ID to Lookup for Customer
-
- nuBuilder Team
- Posts: 4297
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Handover RECORD_ID to another form
This is wrong:
write:
Code: Select all
nuCurrentProperties().cus
Code: Select all
var cus = $("#pro_customer").val();
sessionStorage.setItem('PK_B',cus);