Impossible to submit a form with ticket as a target
I just updated my GLPI instance to v10.0.3 and the plugin FormCreator to v2.13.1 When I fill my forms and click on the submit button, the ticket is created but the form is not submitted with a javascript error :
Uncaught TypeError: xhr.responseJSON is undefined
submitUserForm https://domain.tld/glpi/marketplace/formcreator/js/scripts.js?v=309110d954f295567397918b8ac663ec85f2740b:1395
l https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
fireWith https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
C https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
t https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
send https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
ajax https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
<anonymous> https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46 line 25 > eval:378
prop https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46 line 25 > eval:180
t https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
submitUserForm https://domain.tld/glpi/marketplace/formcreator/js/scripts.js?v=309110d954f295567397918b8ac663ec85f2740b:1384
<anonymous> javascript:plugin_formcreator.submitUserForm():1
To Reproduce Steps to reproduce the behavior:
- Create a form with ticket as target
- Fill and submit the form
- See error in dev console
- See that the ticket is created
Expected behavior The form should be submitted with the confirmation message
Additional context I must launch GLPI in production soon. With GLPI v9.5 and FormCreator v2.12, There was no problem. I tried these commands :
php bin/console glpi:plugin:activate formcreator
php bin/console glpi:database:check_schema_integrity -p formcreator
and GLPI said :
Le schéma de la base de données est OK.
Hi
There are many things which may be the cause of this problem. Several fixes are already waiting for the new release. Can you test the latest revision of the branch support/2.13.0 ?
I disabled the plugin
I deleted the ./marketplace/formcreator folder,
I cloned the repo and moved the folder in the ./plugins directory (with branch support/2.13.0)
I launched composer install --no-dev and yarn install --prod
But I can't activate the plugin. GLPI proposes only to update or to uninstall the plugin although version 2.13.2-dev is displayed.
How could I activate it ?
I tried wih the console : glpi:plugin:activate but formcreator is not in the list
You need to update the plugin from CLI : bin/console glpi:plugin:install formcreator -f -p force-upgrade
I just installed and activated the plugin.
When I submit the form, the submit button is in loading mode (css class spinner-border) and a modal appears with this message :
An internal error occurred. Please report it to administrator.
The ticket is created and the js console displays :
Uncaught TypeError: xhr.responseJSON is undefined
submitUserForm https://domain.tld/glpi/marketplace/formcreator/js/scripts.js?v=309110d954f295567397918b8ac663ec85f2740b:1395
l https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
fireWith https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
C https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
t https://domain.tld/glpi/public/lib/base.min.js?v=0428b61e881008394df330bfd633248732316c46:25
OK, then there is still something to fix. You're probably running PHP 8.1.
Check if you have errors logged in glpi/files/_log/php-errors.log . Select only those relevant to the iussue.
The server runs PHP v7.4. The only error I can see is :
[2022-10-06 15:44:58] glpiphplog.WARNING: *** PHP User Warning (512): No-Reply address is not defined in configuration. in /var/www/apps/glpi10.0.3/src/Config.php at line 3882
Backtrace :
src/Config.php:3882 trigger_error()
src/NotificationTarget.php:1167 Config::getEmailSender()
src/NotificationTemplate.php:594 NotificationTarget->getSender()
src/NotificationEventAbstract.php:136 NotificationTemplate->getDataToSend()
src/NotificationEvent.php:187 NotificationEventAbstract::raise()
src/CommonITILObject.php:7742 NotificationEvent::raiseEvent()
src/Ticket.php:2118 CommonITILObject->handleNewItemNotifications()
src/CommonDBTM.php:1322 Ticket->post_addItem()
plugins/formcreator/inc/targetticket.class.php:907 CommonDBTM->add()
plugins/formcreator/inc/formanswer.class.php:874 PluginFormcreatorTargetTicket->save()
plugins/formcreator/inc/formanswer.class.php:1104 PluginFormcreatorFormAnswer->generateTarget()
src/CommonDBTM.php:1322 PluginFormcreatorFormAnswer->post_addItem()
plugins/formcreator/ajax/formanswer.php:58 CommonDBTM->add()
In the GLPI Menu > Configuration > Notification > E-mail notifications configuration, I set the No-reply adress and the form is successfully submitted. Thanks for your support.
Just a questtion : How can I delete properly the v2.13.2-dev to reinstall v2.13.1 ? The marketplace said that it could not update it because of the database. Should I just delete the plugins/formcreator folder ?
To revert to 2.13.1 you must remove files of the version 2.13.2-dev then reinstall the files of the version 2.13.1
Next, run the following command from CLI : bin/console glpi:plugin:install formcreator -f -p force-upgrade
If you have a warning about differences in the database, you must examine them to see if you need to fix them. You may also use the extra argument -p skip-db-check (but I discourage you do use it, unless you know exactly what you'e doing and you know the consequences of keeping these inconsistencies)
Thanks. But here is the error message. I don't know how to fix the problem.
Traitement du plugin « formcreator »...
Failed to check the sanity of the tables!
The database schema is not consistent with the installed Formcreator 2.13.2-dev. To see the logs run the command bin/console glpi:plugin:install formcreator -f
To ignore the inconsistencies and upgrade anyway run bin/console glpi:plugin:install formcreator -f -p skip-db-check
L'installation du plugin « formcreator » a échoué.
Hi
Do you remember if you had sanity errors when you upgraded to 2.13.1 ?
I think there were no errors. Do you mean I could skip db check ?
Yes, I think you can : this dev versin does not changes anything in the tables.
Hi,
I found this error similar to yours. In my case I was using a ticket template with the predefined filed SLA Time to Resolve defined, and checking the log file tail -f /var/log/glpi/sql-errors.log found this:
Error: Incorrect datetime value: '3170-01-00 08:00:00' for column glpidb.glpi_tickets.time_to_resolve at row 1
After removing the predefined field field, it worked just fine. So I think that the issue is GLPi, not Form Creator.
Hi
Can you show the complete backtrace in the log, matching the error?
Hi
Can you show the complete backtrace in the log, matching the error?
Of course:
[2023-01-31 12:53:07] glpisqllog.ERROR: DBmysql::query() in /var/www/html/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: INSERT INTOglpi_tickets (name, content, itilcategories_id, urgency, impact, priority, requesttypes_id, actiontime, date, entities_id, status, locations_id, global_validation, time_to_resolve, time_to_own, slas_id_tto, slas_id_ttr, internal_time_to_resolve, internal_time_to_own, olas_id_tto, olas_id_ttr, type, users_id_recipient, users_id_lastupdater, slalevels_id_ttr, sla_waiting_duration, date_creation, date_mod) VALUES ('F-TI-04 - Solicitud Cambio de Equipos', '<div><h1>Form data</h1><h2>Información General del Equipo</h2><div><b>1) Acción : </b>Cambio</div><div><b>2) Tipo de equipo : </b>Proyector</div><div><b>3) Area : </b>DO &#62; DU &#62; Castillo &#62; Castillo - 6200 &#62; Cobros</div><div><b>4) Motivo/Uso : </b>one</div><div><b>5) Observación : </b>two</div></div>', '50', '3', '3', '3', '7', '0', '2023-01-31 12:52:48', '1', '1', '772', '1', '3170-01-00 08:00:00', NULL, '0', '2', NULL, NULL, '0', '0', '2', '12', '12', '2', '0', '2023-01-31 12:52:48', '2023-01-31 12:52:48') Error: Incorrect datetime value: '3170-01-00 08:00:00' for column glpidb.glpi_tickets.time_to_resolve at row 1 Backtrace : src/DBmysql.php:1312 src/CommonDBTM.php:716 DBmysql->insert() src/CommonDBTM.php:1321 CommonDBTM->addToDB() ...lace/formcreator/inc/targetticket.class.php:905 CommonDBTM->add() ...tplace/formcreator/inc/formanswer.class.php:975 PluginFormcreatorTargetTicket->save() ...place/formcreator/inc/formanswer.class.php:1259 PluginFormcreatorFormAnswer->generateTarget() src/CommonDBTM.php:1716 PluginFormcreatorFormAnswer->post_updateItem() ...tplace/formcreator/front/formanswer.form.php:53 CommonDBTM->update() {"user":"12@3e3e6651750f"}
I think I should try to reproduce. I'm don't see any clue which ensure that the problem comes from glpi.
What is the value of SLA time to resolve In the template ?
Maximum time: 1 Day Escalation level: -1 day
Thanks. I'll try to reproduce with these values.
Hi, we've a similar problem, when we submit the form we receive this alert:
We have this problem in different versions of the plugin and glpi, this one is GLPI 10.0.14 and formcreator 2.13.9 version
And the only thing we found is in the script.js on the line 1380: if (typeof(xhr.responseJSON) == 'undefined') {
alert(i18n.textdomain('formcreator').__('An internal error occurred. Please report it to administrator.', 'formcreator'));
} but we don't know what generate it
Hi
I tried to reproduce from the information give by @josemalena . It worls well for me.
Can you check if you have a SQL error like to ones already reported ?
Hi, we don't have any sql error related with this