Page 1 of 1
Execute javascript behind a button in a subform
Posted: Sun Mar 03, 2024 12:39 pm
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
Re: Execute javascript behind a button in a subform
Posted: Sun Mar 03, 2024 1:46 pm
by kev1n
Try:
Code: Select all
const $anydeskId = nuSubformRowObject(this.id, 'pos_id_anydesk');
nuMessage("$anydeskid="+$anydeskId.val());
Re: Execute javascript behind a button in a subform
Posted: Sun Mar 03, 2024 3:08 pm
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
Re: Execute javascript behind a button in a subform
Posted: Sun Mar 03, 2024 4:09 pm
by kev1n
Does it work if you launch it from a main form?
Re: Execute javascript behind a button in a subform
Posted: Sun Mar 03, 2024 5:57 pm
by yvesf
Yes working on main form. It is always more complex with subforms.
Re: Execute javascript behind a button in a subform
Posted: Mon Mar 04, 2024 7:50 am
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).
Re: Execute javascript behind a button in a subform
Posted: Sun Mar 10, 2024 12:15 am
by yvesf
thx, working now