I have a form with several lookup objects
each object has a 'SHOW' button that is meant to popup an edit form to show details about the selected lookup object. My difficulty lies in how to retrieve a field from the current database record using Ajax.
Is there an easy way to do this already available? I have looked through the functions in nucommon.js, nuform.js, and nuajax.js but don't see anything that stands out.
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.
Return Selected Lookup ID
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Return Selected Lookup ID
You do not have the required permissions to view the files attached to this post.
TonyD
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Return Selected Lookup ID
Hi,
All you need is the form id (of your Edit Form) and then use this openRecordInPopup() function to pass the form id and the field id of your the lookup object.
The Form Id can be determined by opening the edit form and entering nuCurrentProperties().form_id in the Console (F12). The Form Id is then output.
All you need is the form id (of your Edit Form) and then use this openRecordInPopup() function to pass the form id and the field id of your the lookup object.
Code: Select all
function openRecordInPopup(frm, fld) {
var obj = nuSubformObject('');
var idx = obj.fields.indexOf(fld);
recId = obj.rows[0][idx];
nuPopup(frm, recId);
}
E.g. (replace with your form id and field id)
openRecordInPopup('5a5f6af5d27e4c1', 'your_field_id');
-
- Posts: 68
- Joined: Sun Mar 04, 2018 6:38 pm
Re: Return Selected Lookup ID
Thanks Toms, that worked perfectly.
Do you also have a simple way to get the form ID if you know the form name so I won't have to look up the IDs manually. I just foresee a bug showing up in my code if the form ID changes for some reason, like when deleting and recreating a form.
Thanks again!
Do you also have a simple way to get the form ID if you know the form name so I won't have to look up the IDs manually. I just foresee a bug showing up in my code if the form ID changes for some reason, like when deleting and recreating a form.
Thanks again!
TonyD
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Return Selected Lookup ID
You would have to write a PHP procedure to lookup a form id from a form name.
It's not a big deal if you need know some PHP. Let me know if you need any help with it.
It's not a big deal if you need know some PHP. Let me know if you need any help with it.