Welcome to the nuBuilder Forums!

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

nuPopup() problems

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

nuPopup() problems

Unread post by tonyd »

I have some JavaScript running when the onClick event fires for a button in the hope that it would popup an edit form populated with the current record of a Lookup object on the form:

Code: Select all

nuPopup($('#myDOMObjectId')[0].dataset.nuFormId, $('#myDOMObjectId')[0].dataset.nuObjectId, '');
I get the correct edit form to popup, but it is blank. Any ideas?
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuPopup() problems

Unread post by admin »

tonyd,

What does $('#myDOMObjectId')[0].dataset.nuObjectId return?

Try running nuPopup() with hardcoded values, to see if it does what it should.

Steven
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

Steven,

Well, after some banging of the head on my keyboard, I found out it does not return the record number that I need. Instead, I get the object ID, which doesn't help. Hard-coded values do work, so its not nuPopup().

Any idea how to return the record ID associated with a Lookup object on my form?

Tonyd
TonyD
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuPopup() problems

Unread post by admin »

tonyd,

Try this...

Code: Select all

nuCurrentProperties()
http://wiki.nubuilder.net/nubuilderfort ... Properties


Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: nuPopup() problems

Unread post by toms »

Hi,

You could use

Code: Select all

nuLookupRecord()->ID
to retrieve the record id.

http://wiki.nubuilder.net/nubuilderfort ... okupRecord
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

admin wrote:tonyd,

Try this...

Code: Select all

nuCurrentProperties()
http://wiki.nubuilder.net/nubuilderfort ... Properties


Steven
Nope, just gives the properties of the form, not the Lookup object on the form.
TonyD
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

toms wrote:Hi,

You could use

Code: Select all

nuLookupRecord()->ID
to retrieve the record id.

http://wiki.nubuilder.net/nubuilderfort ... okupRecord
Came back as undefined.
TonyD
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

OK, just to make sure my goal is clear, here is a shot of my "Matters" form, filled with several different nuBuilder objects:
FormWithShowButtons.jpg
What I am trying to do is popup an Edit Form populated with the Lookup object's underlying record data, like this:
EditForm.jpg
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: nuPopup() problems

Unread post by toms »

tonyd wrote: Came back as undefined.
Did you run it in the PHP After Browse Event?

My idea would be to retrieve the primary key of the picked record and then store it in a field.

Code: Select all

nuSetFormValue('yourDOMFieldToStoreTheRecordId', nuLookupRecord()->ID);  
Then, wenn you call nuPopup(), you pass that value as parameter.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: nuPopup() problems

Unread post by tonyd »

toms wrote: My idea would be to retrieve the primary key of the picked record and then store it in a field.

Code: Select all

nuSetFormValue('yourDOMFieldToStoreTheRecordId', nuLookupRecord()->ID);  
Then, wenn you call nuPopup(), you pass that value as parameter.

This worked great! However, there remains a problem in that my yourDOMFieldToStoreTheRecordId is only updated after a browse, which means there is no value upon initial form creation. What I need is for the record ID from any Lookup object to be available when the form is first drawn. Currently, the only way is to put the LookupObjectRecord_id in the 'Code' field of the object, but that just looks ugly.

Just thinking out loud, but is there any part of the current code that draws out each object of the edit form where an attribute could be added to one of the elements to hold the record_id?

Thanks for all of your help!
TonyD
Locked