Hi,
I guess this is discussed already somewhere else but I didn't found it
I have 2 tables
Kultur
- id
- Kultur_Auswahl (Lookup: db_Kultur.Kultur_VTitel)
- Kultur_Text (html)
and
db_Kultur
- id
- Kultur_VTitel (vchar)
- Kultur_Vorlage (html - contains template datasets to be copied to Kultur.Kultur_Text - see below)
How can I realize this:
In "Kultur" I want to add new data. Therefore I select Kultur_Auswahl (lookup) and Kultur_Text is filled with a copy of db_Kultur.Kultur_Vorlage. By saving the "Kultur"-Dataset the data in "sb_Kultur" shouldn't be touched.
I thought this could (somehow) be done by hooks on update events?
Could someone help me?
Regards
Marcus
Insert datda from other table
Re: Insert datda from other table
Kultur.Kultur_Text should stay editable to add additional information
Re: Insert datda from other table
Hi,
you can use the after_insert hook to add the data from the db_Kultur.Kultur_Vorlage to the Kultur.Kultur_Text.
The only drawback is that you need to save the record after selecting the Kultur_Auswahl.
If you want to make it more flexible and handle the changes to the Kultur_Auswahl field, you can use the before_update hook to realize that.
Not sure what you mean by
you can use the after_insert hook to add the data from the db_Kultur.Kultur_Vorlage to the Kultur.Kultur_Text.
The only drawback is that you need to save the record after selecting the Kultur_Auswahl.
If you want to make it more flexible and handle the changes to the Kultur_Auswahl field, you can use the before_update hook to realize that.
Not sure what you mean by
the data in "sb_Kultur" shouldn't be touched.
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.
Re: Insert datda from other table
Are you german? (because of the "ö" in your name...)
If so...
Ich wollte eigentlich damit sagen, dass der Eintrag aus der eigentlichen Tabelle nicht geändert werden soll. Wenn ich "nur ein lookup" benutze und ändere dann etwas, wird ja die Ursprungstabelle geändert. Ich hätte gerne den Datensatz aus der zweiten Tabelle nach der Auswahl in die erste kopiert, verstehe aber nicht ganz, wie das funktionieren soll.
Gruß
Marcus
If so...
Ich wollte eigentlich damit sagen, dass der Eintrag aus der eigentlichen Tabelle nicht geändert werden soll. Wenn ich "nur ein lookup" benutze und ändere dann etwas, wird ja die Ursprungstabelle geändert. Ich hätte gerne den Datensatz aus der zweiten Tabelle nach der Auswahl in die erste kopiert, verstehe aber nicht ganz, wie das funktionieren soll.
Gruß
Marcus
Re: Insert datda from other table
hi,
as this forum is in english, let's stick to it.
The fleld Kultur_Text needs to be a normal field. In the before_insert function you set the data to the template
something like
as this forum is in english, let's stick to it.
The fleld Kultur_Text needs to be a normal field. In the before_insert function you set the data to the template
something like
Code: Select all
$data['Kultur_Text']=sqlvalue("select Kultur_Vorlage from db_Kultur where id={$data['Kultur_Auswahl']}");
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.
Re: Insert datda from other table
Hi,
thanks that nearly worked... thanks,.. but when I try to change the text in Kultur_Text and click on save.... I got a message that the changes couldn't be done.
For explanation. After the text is copied from Kultur_Vorlage to Kultur_Text, I want the Kultur_Text to be editabke. The changes should only applied to Kultur_Text but not to Kulur_Vorlage. Is this possible?
Regards
Marcus
thanks that nearly worked... thanks,.. but when I try to change the text in Kultur_Text and click on save.... I got a message that the changes couldn't be done.
For explanation. After the text is copied from Kultur_Vorlage to Kultur_Text, I want the Kultur_Text to be editabke. The changes should only applied to Kultur_Text but not to Kulur_Vorlage. Is this possible?
Regards
Marcus
Re: Insert datda from other table
Hi Marcus,
how are the fieldsetting in AppGini for that field? If it is a normal field, you should be able to edit the field.
Maybe you can post a screenshot.
how are the fieldsetting in AppGini for that field? If it is a normal field, you should be able to edit the field.
Maybe you can post a screenshot.
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.
Re: Insert datda from other table
- Attachments
-
- 00.PNG (6.09 KiB) Viewed 3550 times
Re: Insert datda from other table
Hi,
isn't there a problem with your suggestion pbötcher? If there is more than the field "Kultur Text" and there are changes to another field, the line of code you suggested will pull the "Beispieltext" again (if there is a value set). Maybe it should be checked first, if "Beispieltexte" holds a value and only then replace the text in "Kultur Text" (or even append to that). Appending would allow composing a "Kultur Text" from different "Beispieltexte"
I noticed a problem in AG 5.92 (still exists in 5.94): viewtopic.php?f=11&t=4085 which might be involved in the problem you are having: As your "Beispieltexte" is not required, it might hold {empty_value} and thus fail some SQL.
Just a thought
Olaf
isn't there a problem with your suggestion pbötcher? If there is more than the field "Kultur Text" and there are changes to another field, the line of code you suggested will pull the "Beispieltext" again (if there is a value set). Maybe it should be checked first, if "Beispieltexte" holds a value and only then replace the text in "Kultur Text" (or even append to that). Appending would allow composing a "Kultur Text" from different "Beispieltexte"
I noticed a problem in AG 5.92 (still exists in 5.94): viewtopic.php?f=11&t=4085 which might be involved in the problem you are having: As your "Beispieltexte" is not required, it might hold {empty_value} and thus fail some SQL.
Just a thought
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Insert datda from other table
Hi,
@Olaf:
this is not the 100% solution, it shall give a startingpoint. As the description of the question is give with only partial information, the solution may not be perfect.
@Marcus,
can you post your hooks/kultur.php ? Is there any other code in that hook?
I tested the feature on my testsystem and it just works fine.
@Olaf:
this is not the 100% solution, it shall give a startingpoint. As the description of the question is give with only partial information, the solution may not be perfect.
@Marcus,
can you post your hooks/kultur.php ? Is there any other code in that hook?
I tested the feature on my testsystem and it just works fine.
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.
Re: Insert datda from other table
Hi,
@pböttcher. I tried to generate the files again to a new fresh directory and than it worked. So thanks for your help!
@pböttcher. I tried to generate the files again to a new fresh directory and than it worked. So thanks for your help!
Re: Insert datda from other table
Hi together... now I have another problem
I added a checkbox called "Zeige_Vorlage". When it is unchecked the Beispieltext-Dropdown (Programm_Vorlage in AG) is not shown and if checked Beispieltext-Dropdown is shown. Checking and unchecking is working well with my programm-dv.js hook which I found elsewhere in the forum here.
I made an entry in the before_insert hook:
What I want is a dropdown field, which is only shown when the checkbox "Zeige_Vorlagen" is checked. And when it is checked I would like to select a text template from the dropdown which fills my other fields (like my first posting above) upon saving. I don't now if I'm using the "if clauses" right?
Could someone help me? Maybe @pböttcher because your tip above worked fine
Regards
Marcus
I added a checkbox called "Zeige_Vorlage". When it is unchecked the Beispieltext-Dropdown (Programm_Vorlage in AG) is not shown and if checked Beispieltext-Dropdown is shown. Checking and unchecking is working well with my programm-dv.js hook which I found elsewhere in the forum here.
I made an entry in the before_insert hook:
and in the before_update hook:$prog1 = $_GET['Progrann_Vorlage'];
if ((!isset($prog1)) || ($prog1 != NULL)){
$data['Prozess']=sqlvalue("select Prozess from db_programm where id={$data['Programm_Vorlage']}");
$data['Programm_Vorlage'] = NULL;
return TRUE;
and it gets the correct selected templates in the field "Prozess" on saving. But when I try to change the text in "Prozess" and click on "save" I get the data from the origin template. Also on a new dataset when I don't click the checkbox to use a template and edit "Prozess" whith individual data, there is only saved a "NULL" on "Prozess".$prog1 = $_GET['Programm_Vorlage'];
if ('Programm_Vorlage' != NULL)
$data['Prozess']=sqlvalue("select Prozess from db_programm where id={$data['Programm_Vorlage']}");
$data['Programm_Vorlage'] = NULL;
return TRUE;
What I want is a dropdown field, which is only shown when the checkbox "Zeige_Vorlagen" is checked. And when it is checked I would like to select a text template from the dropdown which fills my other fields (like my first posting above) upon saving. I don't now if I'm using the "if clauses" right?
Could someone help me? Maybe @pböttcher because your tip above worked fine
Regards
Marcus