Delete or insert a record with run button in a grid

The question is: What is the best solution when I want insert or delete a record directly via a run button in a grid. (not going to the detail form first).
It is impossible to do it with "sc_exec_sql (“delete …etc”) because a grid does not allow from security a delete or insert
Would be nice to get a hint…

The pittfall is that everything work fine in the develoment (security off) but not in the production.

Regards Bert

You can use sc_exec_sql then reaload the grid.

Sorry, in my application it is not working…the sc_exec_sql hangs up the application (a grid in this case). I mean in development perfect, but in production not.
My escape is to go to the detail form and do there the sql_actions. This works, but this is not what i want.

no error message (ajax or in chrome)? Maybe something with the right settings on your production? Or the prod database is missing a field, is another type, another length?USe de debug to see the exact sql string executed.

Also in the debug mode no errors. Still it has something to do with rights…I going to check

I checked everything about security. Something must have been changed in using sc_exec_sql in the latest version. It was not before.

It still is a big issue for me. I can not run sc_exec_sql via a run button (or other event) in a grid…In development yes, in production no

For your info: The sc_exec_sql runs perfect in a form, but not via a grid. And before the upgrade to the latest version (14) there was no problem.

post your code here to run the sql through a button in a grid. I will try to make a grid and check in my production

Hi nokelmike,

In the run button in “on record” there is this code:

$currentIndex = [current_index];
[checked_array][$currentIndex] = {id};
[current_index]++;
$n = count([checked_array]);
$i = 0;
while ($i < $n){
test();
$i++;
}
sc_reset_global([checked_array]);

The sc_exec_script test():

$var_name = {name};
sc_exec_sql (“insert into naw (naam) values (’$var_name’)”);

I think the problem comes from the $n = count([checked_array])

I tried the sc_exec_sql macro in a RUNbutton. This is working like it should