I have this PHP function running during an onBeforeInsert evet
$v_subjectid = {subject};
$v_contactID = {contactID};
$sql_insert_ticket = “INSERT INTO tickets(subject
,contactID
,customerID )
VALUES( ‘$v_subjectid’,
‘$v_contactID’,
(select customerID from asinvdb.customerContacts where contactID = ‘$v_contactID’)
)”;
sc_exec_sql($sql_insert_ticket);
This runs fine and adds the data to the tickets table.
I am then trying to query the tickets table for the ticketID for the recently created record and pass that value back to a local variable/field called {idticket}.
I am running into foreign key issues as the form is using a the ticketDetail table and the idticket field has a foreign key setup to the idTicket from the tickets table. If I run the below command on teh database manually (outside of scriptcase) it runs fine.
INSERT INTO asinvdb.ticketDetail (idticket, staffID, contactID, ticketDetailDate, ticketContent, ticketAssignStatus)
Values ((select idTicket from asinvdb.tickets where subject = ‘radio’),2, 98, null, ‘broken’, 1)
Where and how is the best place to set the value for this forms local {idticket} variable?
Thanks,