Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Return Selected Lookup ID

Questions related to using nuBuilder Forte.
Post Reply
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Return Selected Lookup ID

Unread post by tonyd »

I have a form with several lookup objects
FormLookupObject.JPG
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.
You do not have the required permissions to view the files attached to this post.
TonyD
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Return Selected Lookup ID

Unread post by toms »

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.

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');
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.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Return Selected Lookup ID

Unread post by tonyd »

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!
TonyD
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Return Selected Lookup ID

Unread post by toms »

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.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Return Selected Lookup ID

Unread post by admin »

.
Post Reply