Hello, I have a quick question.
I have a form that opens in a modal, and here you can add a new record.
The PK field is not displayed (recordID), because it’s autoincrement, so whenever you add a new record, it will auto assign an ID.
Up to here everything works, I can save the record and it will show in the Grid application.
I have an issue where I create a php Button for this form, called “Save and view details”.
What this button should do, once the form for the new record is filled, instead of just using the default Save button, I want another button that does the same, it saves this record, but then, it redirects to another form, where I can add more details for this record.
Usually what I would do is, add a new record, go to my Grid, see the new record and click on it (each record has a field link so you can click on it), after clicking I would get redirected to the second form (record_details) where I show some details about the record.
So to avoid all these extra steps, how can I code that custom button to Save as the default button, but then redirect to my other form? The other form takes only one parameter as input, which is the “recordID”, the one that gets autoassigned when creating a new record.
I tried creating a button as php, and adding this code:
$sql_insert = "INSERT INTO dbo.TblItem(ItemTyp, ItemName, ItemBeschreibung, ItemProduktID, ItemKundeID, ItemMitarbeiterID) VALUES ( '{ItemTyp}','{ItemName}','{ItemBeschreibung}','{ItemProduktID}','{ItemKundeID}','{ItemMitarbeiterID}')";
sc_exec_sql($sql_insert);
sc_redir('record_details', parm1={ItemID}, '_parent');
so the insert part works correctly, the record gets saved with the correct values,
what doesnt work is the SC_REDIR, I get redirected to my “record_details” page, but without any record selected, so that means no record was passed (this form is just to modify a single record, so it takes as input the record ID and shows all the informations).
I’m not sure what the issue is.
Does it matter that when creating a new record, the ID as not being shown because of autoincrement, when I press my custom button, it cannot somehow retrieve the ID? even if I use the field value of the ID?