Button Object in subform

Button Object in subform

Postby ruiascensao » Thu Sep 04, 2014 11:47 pm

Hi,

I have a button in a subform that would open that record in an edit screen.
open.jpg
open.jpg (13.14 KiB) Viewed 11089 times

button.jpg
button.jpg (26.32 KiB) Viewed 11089 times


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.
BR
Rui
ruiascensao
 
Posts: 177
Joined: Tue Nov 15, 2011 10:54 pm

Re: Button Object in subform

Postby admin » Fri Sep 05, 2014 12:17 pm

Rui,

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

Steven
admin
Site Admin
 
Posts: 3267
Joined: Mon Jun 15, 2009 9:53 am

Re: Button Object in subform

Postby ruiascensao » Sat Sep 06, 2014 1:03 am

Hi Steven,

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

Thank you.
BR
Rui
ruiascensao
 
Posts: 177
Joined: Tue Nov 15, 2011 10:54 pm

Re: Button Object in subform

Postby admin » Tue Sep 09, 2014 7:33 am

Rui,

Does it work with the record id hardcoded?

Steven
admin
Site Admin
 
Posts: 3267
Joined: Mon Jun 15, 2009 9:53 am

Re: Button Object in subform

Postby ruiascensao » Wed Sep 10, 2014 4:05 am

Hi Steven,

Yes, it does work with the id hardcoded but does not with the hash variable #SUBFORM_RECORD_ID#.
BR
Rui
ruiascensao
 
Posts: 177
Joined: Tue Nov 15, 2011 10:54 pm

Re: Button Object in subform

Postby admin » Tue Sep 16, 2014 9:13 am

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/Javascript_Functions#nuRowPrefix.28pThis.29

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

eg.
Code: Select all
$('#' + nuRowPrefix(this) + '_nuPrimaryKey').val()


Steven
admin
Site Admin
 
Posts: 3267
Joined: Mon Jun 15, 2009 9:53 am

Re: Button Object in subform

Postby steve foley » Sun Aug 09, 2015 11:25 am

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?
steve foley
 
Posts: 8
Joined: Tue Aug 04, 2015 4:06 am

Re: Button Object in subform

Postby admin » Mon Aug 10, 2015 5:00 pm

admin
Site Admin
 
Posts: 3267
Joined: Mon Jun 15, 2009 9:53 am

Re: Button Object in subform

Postby steve foley » Wed Aug 12, 2015 10:56 am

Unfortunately, I still have no idea what to do with this code, or where to put it.
steve foley
 
Posts: 8
Joined: Tue Aug 04, 2015 4:06 am

Re: Button Object in subform

Postby admin » Wed Aug 12, 2015 12:23 pm

steve,

You put can call a javascript function on a button here..

Capture2.PNG
Capture2.PNG (26.03 KiB) Viewed 10744 times


And create the function here..

Capture3.PNG
Capture3.PNG (23.88 KiB) Viewed 10744 times


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
admin
Site Admin
 
Posts: 3267
Joined: Mon Jun 15, 2009 9:53 am

Next

Return to General