Page 1 of 2

nuPopup() problems

Posted: Sun Mar 04, 2018 7:01 pm
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?

Re: nuPopup() problems

Posted: Sun Mar 04, 2018 10:36 pm
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

Re: nuPopup() problems

Posted: Sun Mar 04, 2018 11:35 pm
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

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 12:55 am
by admin
tonyd,

Try this...

Code: Select all

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


Steven

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 1:10 am
by toms
Hi,

You could use

Code: Select all

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

http://wiki.nubuilder.net/nubuilderfort ... okupRecord

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 2:37 am
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.

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 2:38 am
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.

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 3:36 am
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

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 6:30 am
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.

Re: nuPopup() problems

Posted: Mon Mar 05, 2018 12:51 pm
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!