Hi,
I developed a form in which some values are proposed by default based on last value inserted + 1 . For istance last value inserted 10/2019 , new proposed value 11/2019
It seems easy … and I did some code that works in onApplicationInit :
sc_apl_conf(“form_ticket”, “start”, “new”);
$sql_next_rec="SELECT CONCAT(IFNULL(MAX(SUBSTRING_INDEX(id_ticket
, ‘/’, 1)), 0) + 1 ,’/’, YEAR(CURDATE())) FROM ticket ";
sc_lookup(rs, $sql_next_rec);
if (isset({rs[0][0]})) // Row found
{
[glo_next_id] = ({rs[0][0]}) ;
{id_ticket}= [glo_next_id];
$num_prog = explode(’/’,{id_ticket});
[glo_index_ticket] = $num_prog[0];
{ticketid} = [glo_index_ticket];
}
When I run the application the first time everything works as expected . Es 10/2019
The issue is when I click on Insert button and SC save the record. Then using sc_apl_conf(“form_ticket”, “start”, “new”); I was expecting that new record proposed has had the right value
but it don’t work . It has still the previous value Es 10/2019 instead of 11/2019.
I did try also to copy the same code above into onScriptInit but nothing change. I also tryed to insert a sc_redir (sameform) in onAfterInsert but no way again…
I’m here stucked…
Can someone help me ?
Thanks