Hi,
My name is Craig Campbell, I work with Bevil at Templeton-Smith Ltd.
I have a problem when it comes to identifying forms in Servoy methods. I have code that identifies the form correctly when I’m creating a new database record. However, the same code wont work when I’m trying to control record deletion.
A simplified version of my code for adding a new record is listed below:
var thecurrentform = currentcontroller.getName();
if (thecurrentform == 'birthstones')
{
currentcontroller.newRecord();
forms.birthstones.create_related_record();
}
The actual code in my method has conditions for a large number of forms, but you don’t need to see all that.
The code for controlling record deletion is listed below:
var thecurrentform = currentcontroller.getName();
if (thecurrentform == 'birthstones')
{
// Don't do anything
}
else
{
var thePressedButton = plugins.dialogs.showWarningDialog('Are you sure', 'Are you sure you want to delete the selected\n' + 'line. This cannot be undone','OK', 'Cancel');
if (thePressedButton == 'OK')
{
controller.deleteRecord();
}
}
I just need to prevent records from being deleted from the ‘birthstones’ form. Records can be deleted from all other forms.
Anyway, the condition that checks the form name in the new record method works fine. It always identifies the correct form and a record is then created in the correct database table. However, when it comes to deletion, the record is always deleted even if it’s in the ‘birthstones’ form. Therefore the condition that checks the form name just doesn’t work for some reason.
I’ve even tried setting the delete method up with the following code, but this still deletes records from any form, including the ‘birthstones’ form.
var thecurrentform = currentcontroller.getName();
if (thecurrentform != 'birthstones')
{
var thePressedButton = plugins.dialogs.showWarningDialog('Are you sure', 'Are you sure you want to delete the selected\n' + 'line. This cannot be undone','OK', 'Cancel');
if (thePressedButton == 'OK')
{
controller.deleteRecord();
}
}
I am sure that there is something very simple that causing this problem. I just don’t know what it is. Therefore, please let me know if you can see what’s wrong with my code.
Craig