Page 1 of 2

Button Object in subform

Posted: Thu Sep 04, 2014 4:17 pm
by ruiascensao
Hi,

I have a button in a subform that would open that record in an edit screen.
open.jpg
button.jpg
I'm using the hash variable #SUBFORM_RECORD_ID# .
But when I click in the button it opens the form but with empty fields.

Could you please advise?

Thank you.

Re: Button Object in subform

Posted: Fri Sep 05, 2014 4:47 am
by admin
Rui,

Has that subform record previously been saved? Because it won't have an Primary Key until it does.

Steven

Re: Button Object in subform

Posted: Fri Sep 05, 2014 5:33 pm
by ruiascensao
Hi Steven,

Yes, I have a record saved in the subform (goodin_subform).

Thank you.

Re: Button Object in subform

Posted: Tue Sep 09, 2014 12:03 am
by admin
Rui,

Does it work with the record id hardcoded?

Steven

Re: Button Object in subform

Posted: Tue Sep 09, 2014 8:35 pm
by ruiascensao
Hi Steven,

Yes, it does work with the id hardcoded but does not with the hash variable #SUBFORM_RECORD_ID#.

Re: Button Object in subform

Posted: Tue Sep 16, 2014 1:43 am
by admin
rui,

Come to think of it #SUBFORM_RECORD_ID# is used by Display Objects or Lookup Objects not Javascript.

To get the ID you can use this JavaScript function http://wiki.nubuilder.net/index.php/Jav ... 28pThis.29

You can use nuRowPrefix(this) or nuRowNumber(this) to find the row number.

eg.

Code: Select all

$('#' + nuRowPrefix(this) + '_nuPrimaryKey').val()
Steven

Re: Button Object in subform

Posted: Sun Aug 09, 2015 3:55 am
by steve foley
This looks like it may solve the problem i posted, but I have no idea where to put this code or what to put into the 'Record ID" field on the button.

Can someone point me in the right direction?

Re: Button Object in subform

Posted: Mon Aug 10, 2015 9:30 am
by admin

Re: Button Object in subform

Posted: Wed Aug 12, 2015 3:26 am
by steve foley
Unfortunately, I still have no idea what to do with this code, or where to put it.

Re: Button Object in subform

Posted: Wed Aug 12, 2015 4:53 am
by admin
steve,

You put can call a JavaScript function on a button here..
Capture2.PNG
And create the function here..
Capture3.PNG

Code: Select all



function myFunction(){

    var id = $('#' + nuRowPrefix(this) + '_nuPrimaryKey').val();
    
    nuOpenFormInFrame('55494eebbb1c5d0', id);   //**** you need to find out the Form's ID in the database

}



Steven