Master/Detail form, change how the delete button works

I have a master/detail form, and on the detail form, there is a delete button for each row(it looks like a trash can). Instead of deleting the record, I would like to change a field called ‘status’ from ‘active’ to ‘deleted’. How would I go about doing that?

Re: Master/Detail form, change how the delete button works

I supose you can create a Select field with the status, and if you want to edit a specific record you change it and update the field

Re: Master/Detail form, change how the delete button works

As far as I know not a standard feature of SC.

Some thougths:
you can remove the delete button in the detail in the link properties of the master by unchecking “enable delete button”. However, you can’t add a custom button in the grid, this will have to a be field of another datatype (visually change it to look like a button?). Then you can use javascript onclick to set the value of your status field. To click the custom button however, you have to click the “edit this record” before you can click on the custom button… Not really nice.

Maybe you can create a custom button on the master that updates directly in the database en reloads the form to make the changed value visible? I don’t know how to adress a field in a row of a grid.

Re: Master/Detail form, change how the delete button works

thanks for the response, I thought that if I redirected the page in the onBeforeDelete event, then it wouldn’t delete it. Right now I think it doesn’t delete but it doesnt change the status. Would I need to use my own SQL to update the table?

Re: Master/Detail form, change how the delete button works

You could just remove the delete option from your detail form and then perform the following:

-Create a new field (Html image), select image for button
-Create an sc_link() to a control form, send the key value in sc_link
(In V5 you could make this a modal option it you wanted.)
-In the control form, grab the value of the key
-control form.onValidate, execute your custom sql to change field value
-reload other form to display new value.

Regards,
Scott.

Re: Master/Detail form, change how the delete button works

Then you still have to click the “edit this row” first before the new button in the grid is available don’t you?
And do you have to click something in the control window to make the onvalidate trigger fire?

Re: Master/Detail form, change how the delete button works

You got me …

You could send it to a ‘blank’ app and then there would be no button to click, or even setup a sc_redirect in the control app that will bypass the ok, or remove the Ok button from the toolbar… but then it is just getting ugly :wink:

If you want a live click and change on the same form, then AJAX would be the solution so you do not have to reload the PHP form.

Or did I misunderstand the question. That happens :wink:

Regards,
Scott.

Re: Master/Detail form, change how the delete button works

What I want to do is if the user clicks ‘delete’, it should change that row’s status to ‘deleted’, and then I guess reload the page, that way, I can put a check in the onLoad or onInit, and if a row has a status of deleted, don’t show it.

Right now, if I reload the page, it doesn’t delete the record, which is what I want it to do. I was just wondering if there was a way to update the status, without using my own SQL. I was just being lazy and also trying to figure out more about SC. From my experience, if they had better documentation, things would be easier. There are a couple things I coded myself, just to realize I couldve done it an easier way.

Re: Master/Detail form, change how the delete button works

There are still a few problems/challenges remaining in finding a solution to this problem:

  1. the delete record functionality cannot be changed
  2. you cannot add a custom button for each line that can be cklicked without first clicking the “edit this row” button
  3. unfortunately an SC form application of type multi-record cannot be selected as a detail form (if so that would solve 2)
  4. how can you address a field in a grid using javascript? document.F1.fieldname.value won’t work because there can be more that one row in the grid…

I would suggest that you contact support about your issue. Please let us know here what they came up with. Thanks.