Welcome to the nuBuilder Forums!

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

Execute javascript behind a button in a subform Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
yvesf
Posts: 337
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 92 times
Been thanked: 11 times

Execute javascript behind a button in a subform

Unread post by yvesf »

Hello,

I would like to run a javascript behind a button in a subform.
I have generated the button "lancer anydesk" which is my ultimate objective : launch anydesk program.
Capture d’écran 2024-03-03 122638.png
I need to retrieve the value of a field in the current record. Here is the script :

Code: Select all

$anydeskid=nuGetValue('pos_id_anydesk');
nuMessage("$anydeskid="+$anydeskid);
This script works perfectly in edit mode but not when I click it on the line in the subform
In edit mode :
Capture d’écran 2024-03-03 123416.png
In the subform
Capture d’écran 2024-03-03 123555.png
How can I solve this pb ?
Many thx,

Yves
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Execute javascript behind a button in a subform

Unread post by kev1n »

Try:

Code: Select all

const $anydeskId = nuSubformRowObject(this.id, 'pos_id_anydesk');
nuMessage("$anydeskid="+$anydeskId.val());
yvesf
Posts: 337
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 92 times
Been thanked: 11 times

Re: Execute javascript behind a button in a subform

Unread post by yvesf »

Great thanks. I have to launch the browser. how to make that working from the subform ?
Here is the code :

Code: Select all

const $anydeskId = nuSubformRowObject(this.id, 'pos_id_anydesk');
//nuMessage("$anydeskid="+$anydeskId.val());
 var url = 'anydesk://ad/' + $anydeskId;
 window.location.href = url;
I would like to launch anydesk executing this url.
How could I do that ?

thx,

Yves
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Execute javascript behind a button in a subform

Unread post by kev1n »

Does it work if you launch it from a main form?
yvesf
Posts: 337
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 92 times
Been thanked: 11 times

Re: Execute javascript behind a button in a subform

Unread post by yvesf »

Yes working on main form. It is always more complex with subforms.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Execute javascript behind a button in a subform

Unread post by kev1n »

There should be no difference if you call window.location.href = url; either from a form or a subform since the subform is not in a separate iframe. check that the url is correct and no errors are displayed (check the developer console).
yvesf
Posts: 337
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 92 times
Been thanked: 11 times

Re: Execute javascript behind a button in a subform

Unread post by yvesf »

thx, working now
Post Reply