where is Save As Copy Function ??

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: where is Save As Copy Function ??

Post by pbottcher » 2020-04-10 19:00

I dont think you undersood what save as copy does?

It is the same as insert new record. So you can ONLY use the before_insert and after_insert hooks.

Within those two hooks you have access to all the data from the form, so you can do what you want. Run SQL, modify the data, send email, put into another table, ...
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1817
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: where is Save As Copy Function ??

Post by jsetzer » 2020-04-10 19:12

its possible or not ????
Short answer: yes, it is possible

pböttcher has already answered your question in his very first post after your question. Olaf has also given correct answers. Both of them have given working, useful and correct tips. So I agree with them: I do not understand your problem.

Did you try what they suggested? What exactly does not work when following their instructions?

As mentioned by the guys before, you can...

write your php code in _before_insert() hook and modify $data array

or

write your php code in _after_insert() hook and update your data by using sql commands

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-10 19:34

yes i try
very simple ,,,, if you try after_insert will run query once i press on Save Now or Save ...
for example if i run Query like this
(( its just example ))

Code: Select all

$data['total'] = $data['quantity'] * $data['unit_price'];
will run Query once i press on Save Now OR save
its mean i just create the record now ,,, so Query is run ,,, no problem

but when row is already there and i want is only change some information in the existing row then Save As Copy will Save copy of the row with new information and keep old row is same .
also will run

Code: Select all

$data['total'] = $data['quantity'] * $data['unit_price'];
Again

i hope someone try that ...
i can make JavaScript and Ajax ,

Save As Copy As Button on AppGini why there in function in Hooks same like After_insert or before_insert !!!!!!!!!!!!!!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: where is Save As Copy Function ??

Post by pbottcher » 2020-04-10 19:39

Hi,

you stiil ignore what we try to tell you:

Save a new record == Save as Copy for an existing record. It will ALWAYS create a new record.

If you want just to change some data on an exising record there is the magic button"SAVE CHANGES".
This will NOT create a new record, but update the existing record with the new data.

ALSO this will trigger the before_update and after_update functions !!
NOT the before_insert and after_insert !!
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-10 19:47

i am not Ignore anything ,,, i am here to learn
i want you only now one thing

I WANT RUN Query when i press on Save As Copy ( ONLY )
if i add query with after_insert function will run Query when press Save Now ,,, Plus next time when i press Save As Copy will run Query Again

you can try it then you teach me what you find

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: where is Save As Copy Function ??

Post by pbottcher » 2020-04-10 20:32

Hi,

Sorry, but unless you expain what you try to achieve we cannot help you.

You CANNOT use Create NEW RECORD and SAVE AS COPY differenty. THEY ARE THE SAME !!

If you want to modify a record use SAVE CHANGES on an existing RECORD. SAVE AS COPY is not the function to use !!
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-10 20:35

thanks A lot :)

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1167
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: where is Save As Copy Function ??

Post by onoehring » 2020-04-11 08:20

Hi,

I just had the idea what xbox might mean with this
I WANT RUN Query when i press on Save As Copy ( ONLY )
if i add query with after_insert function will run Query when press Save Now ,,, Plus next time when i press Save As Copy will run Query Again

you can try it then you teach me what you find
Maybe he means, if, and only if the button SAVE AS COPY is pressed some extra SQL (or whatever) should be run - but not when a new record is being created using the "SAVE" button.
As pbötcher described SAVE AS COPY is essential creating a new record, one would need to check if some flag(s)/row(s) of the new record can be found in the old records - this might actually be possible, depending on the database design (which I doubted above). If some flag(s)/row(s) of the new record match those of the existing ones, the SAVE AS COPY button has been pressed, if nothing like this exists, the "SAVE NEW" button has been pressed.

But maybe xbox means something else .... and I am sure what he want's to do with that and why (which intrigues me that there might be (much) easier ways to accomplish the desired result).

pbötcher and Jan have much more experience with and knowledge about AppGini than most of the people in this forum (imho). They are giving their precious time for free to others and they are trying to help. Please be nice to them, this forum needs them!

Olaf

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-11 19:37

hello , thanks a lot onoehring

i was explain what i want many time i also add photo many time they make me feel like i am stupid


i already know , Save Now , and Save As Copy create new record
so i want run some Query i should add on After_insert ( not other function )

BUT if i add MySQL Query with After_insert function will run Query two time

first time when i press Save Now
second time when i press Save As Copy

also i know how i can make it with JavaScript and Ajax

I was ask if we can make Function for Save As Copy in Hooks same function for After_insert or After_update ????

That all

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: where is Save As Copy Function ??

Post by pbottcher » 2020-04-11 19:59

Hi again,

and sorry again, but in the whole conversation there is no clear statement about what eaxctly you try to achieve.

All I get is that you want a "after_save_as_ copy" function whithout knowing why.

Why cant you make an example of what you want to do?

Do you want to create a second record (Save as copy), but handle this record differently (meaning what do you want to do with this record)
Or do you want to have just another function that you want to call for handling the data of the same record?
Or do you want to modify the existing record and have some additional task to the original or modified record?

Allo open to me.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-11 20:56

thanks for you for your care

i already manage what i want do with other way

thanks a lot

David Soul
Veteran Member
Posts: 31
Joined: 2018-01-04 18:32
Location: Vancouver, Canada
Contact:

Re: where is Save As Copy Function ??

Post by David Soul » 2020-04-12 07:08

Wow. Just Wow.
Thanks for all your patience everyone that tried to help the chap that refused to be helped.

As a "lurker" on so many of your threas I have learned things that I never would have thought to question myself - and then found them to be useful!
Thanks so much for all you do for this community!
David HC Soul

Core::AppGini 5.93
Plugins: Search Page Maker + Summary Reports + Mass update plugin
Bizzworxx: AppGini Helper JavaScript Library + AppGini Helper Detail View Plug-in + AppGini Helper pack
Utilities: Global Search utility

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: where is Save As Copy Function ??

Post by xbox2007 » 2020-04-12 09:28

thanks you very much

thanks for everyone ,,

i am here to learn , if i know something i like to share it with other

omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

Re: where is Save As Copy Function ??

Post by omackeytech » 2024-02-28 00:54

The 'save as copy' calls a CURL function in the incfunctions.php in the admin section as far as I can tell.
Playing with it right now and will let you know what I find.

Post Reply