Welcome to the nuBuilder Forums!

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

nuSelectBrowse opening nuUserhome?

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

nuSelectBrowse opening nuUserhome?

Unread post by benritter »

Hello,
I'm trying to use the nuSelectBrowse function. When I click on a record in a browse form (which is displayed in an iframe) I want it to open the edit form, filled with values from the browse form. I am using this code in the JavaScript of the browse form.

function nuSelectBrowse(e){

var r = $('#' + e.target.id).attr('data-nu-primary-key');

nuForm(nuGetProperty('client_id'), '-1', '', '', '0');
}

'client_id' is the PK of my form.
With this code, When I click on a record in the browse form, It opens the nuUserhome launch form.
I suspect that I am using the wrong values in the 'form_id' and 'record_id' places.
I have also tried eliminating the middle line of code so it's just a nuForm inside the nuSelectBrowse, and I get the same result. Any ideas?
Thanks.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: nuSelectBrowse opening nuUserhome?

Unread post by Janusz »

Hi,
The first parameter of nuForm is the form ID - originally it's nuGetProperty('form_id')
if you want to redirect to any other form you have to indicate other form ID.
e.g. nuForm("5c23e11c067a524",a,'', '');
and following can be helpfull:
https://forums.nubuilder.cloud/viewtopic. ... led#p18553
If you like nuBuilder, please leave a review on SourceForge
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: nuSelectBrowse opening nuUserhome?

Unread post by benritter »

Thanks!
I got the proper 'form_id' using f12 and placed it in where nuGetProperty was. And now clicking on a browse form row opens the edit form.
Is there a way to fill the edit form with all the saved values in the table based on the PK of the selection in the browse form?
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: nuSelectBrowse opening nuUserhome?

Unread post by benritter »

maybe with nuGetLookupId('my_form_id', 'object id from edit form'); ?
Even if I had to manually do a nuLookupId for each object, that would be doable.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: nuSelectBrowse opening nuUserhome?

Unread post by Janusz »

not sure if I properly understand the subject

I assume that from one browse form you want to open other edit form
(in case of the same browse/edit form you have direct access to all table values both in browse and edit form)

so if you want to go to other edit form you can first read the values of the browse form from selected record for example:

Code: Select all

function nuSelectBrowse(e){
   var row   = $('#' + e.target.id).attr('data-nu-row');
   var col0 =  $('#nucell_' + row + "_" + 0).html();
   var col1 =  $('#nucell_' + row + "_" + 1).html();
   var col2 =  $('#nucell_' + row + "_" + 2).html();
console.log(row,col0,col1,col2);
}
(and you can check the values in the console)
next you can set the the session storage items, open new edit form, and set the stored values to the specific fields as in the
https://forums.nubuilder.cloud/viewtopic. ... led#p18553
If you like nuBuilder, please leave a review on SourceForge
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: nuSelectBrowse opening nuUserhome?

Unread post by benritter »

I did have separate browse and edit forms accessing the same table. I just changed the form running in my browse iframe to the same form as the edit form. Now it works. Thank you.
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: nuSelectBrowse opening nuUserhome?

Unread post by benritter »

I am having a new issue now. I keep getting the message:
fatal error.png
After changing my edit only form and subform to browse and edit, I deleted the old browse only forms. Maybe that's what caused it?
It seems like an infinite loop. How do I find where the code is bad?
You do not have the required permissions to view the files attached to this post.
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: nuSelectBrowse opening nuUserhome?

Unread post by benritter »

I fixed this. I had a join in the browse SQL of the old browse only form. like this:
SELECT
*
FROM
(
SELECT
household.*,
client.client_number
FROM
household
LEFT JOIN client ON household.client_id = client.client_id
) T

so that I could search subform entries based on the parent form id. When I deleted the old browse only, I think that created a data loop when it was trying to make the connection.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: nuSelectBrowse opening nuUserhome?

Unread post by admin »

well done.
Post Reply