[SOLVED] Duplicate record, but not appear!

Hi,

Sorry, screenshot in french

I created a button to duplicate a recording. The record is showing up in the database, but I can’t see it on the screen, even when I press the button to refresh.

I have to exit the form and re-enter to see it. Do you have any idea how to solve this?

Thank you

If it’s a grid you need to refresh it

sc_ajax_refresh();

Hi jlboutin60,

It’s form in detail/master view :

Because : Fatal error: Uncaught Error: Call to undefined function sc_ajax_refresh()

It’s only available on grid

try javascript

echo "<script>
   window.location.reload ();
</script> ";

or

echo "<script>
   window.parent.location.reload ();
</script> ";

Hi,

sc_begin_trans();
sc_exec_sql($sql);
sc_commit_trans();
//sc_redir(formulaire_gouvernement.php);
echo “<script> window.location.reload();</script>”;

Infinite duplication in database :wink:

so location is the button, and parent.location should be the form

Thank you for your help.

With windows.PARENT.location it works, but I don’t want to reload the entire form, but just the detailed view.

So is should be parent.blockname.location (id of blockname)

Oh my god ! Your name is god ?? lol

echo “<script>parent.formulaire_usagers_form2.location.reload();</script>”;

But this is result :

It works, but I have to press OK

try to add

sc_exit(sel);

after the javascript

Same with : echo “<script>parent.nmsc_iframe_liga_formulaire_gouvernement.reload();</script>”;

Maybe I don’t have the right name of the iframe to refresh?

Ok let me try this now : sc_exit(sel);

Final solution is simple :

sc_begin_trans();
sc_exec_sql($sql);
sc_commit_trans();
sc_exit(sel);

How do you know all this ??
A big big thank you!

I found out that I am learning a lot when I am helping or trying to help other

2 Likes

Hi jlboutin60,

Here are finally the lines that work :

I too learned a lot with you, I will pass it on to others;)

Thank you.

2 Likes

The only problem I still see is after loading, I see two recordings. The first is the original recording (ex. 9 february 2021) and the second is also the original recording.

It does not apply the order of my request to refresh and displays the most recent record (21 february 2021 - duplicate record).

After the duplication I have to go to the second record and after the first to see the correct duplicated record.

Finally I cheated, I duplicated (INSERT) the record and I modified (UPDATE) the record with the current date so that it appears first. :

SOLVED !

1 Like

sc_exit(sel); go back to the same selection

sc_exit(ref); will go back and refresh

2 Likes

Yes, I had tested both but without success!