formcreator icon indicating copy to clipboard operation
formcreator copied to clipboard

Impossible to submit a form with ticket as a target

Open paidge opened this issue 3 years ago • 22 comments

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:

  1. Create a form with ticket as target
  2. Fill and submit the form
  3. See error in dev console
  4. 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.

paidge avatar Oct 05 '22 15:10 paidge

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 ?

btry avatar Oct 05 '22 15:10 btry

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

paidge avatar Oct 06 '22 12:10 paidge

You need to update the plugin from CLI : bin/console glpi:plugin:install formcreator -f -p force-upgrade

btry avatar Oct 06 '22 13:10 btry

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

paidge avatar Oct 06 '22 13:10 paidge

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.

btry avatar Oct 06 '22 13:10 btry

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()

paidge avatar Oct 06 '22 14:10 paidge

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.

paidge avatar Oct 06 '22 14:10 paidge

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 ?

paidge avatar Oct 13 '22 13:10 paidge

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)

btry avatar Oct 13 '22 13:10 btry

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é.

paidge avatar Oct 14 '22 07:10 paidge

Hi

Do you remember if you had sanity errors when you upgraded to 2.13.1 ?

btry avatar Oct 14 '22 07:10 btry

I think there were no errors. Do you mean I could skip db check ?

paidge avatar Oct 14 '22 07:10 paidge

Yes, I think you can : this dev versin does not changes anything in the tables.

btry avatar Oct 14 '22 07:10 btry

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.

josemalena avatar Jan 31 '23 16:01 josemalena

Hi

Can you show the complete backtrace in the log, matching the error?

btry avatar Jan 31 '23 17:01 btry

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', '&#60;div&#62;&#60;h1&#62;Form data&#60;/h1&#62;&#60;h2&#62;Información General del Equipo&#60;/h2&#62;&#60;div&#62;&#60;b&#62;1) Acción : &#60;/b&#62;Cambio&#60;/div&#62;&#60;div&#62;&#60;b&#62;2) Tipo de equipo : &#60;/b&#62;Proyector&#60;/div&#62;&#60;div&#62;&#60;b&#62;3) Area : &#60;/b&#62;DO &#38;#62; DU &#38;#62; Castillo &#38;#62; Castillo - 6200 &#38;#62; Cobros&#60;/div&#62;&#60;div&#62;&#60;b&#62;4) Motivo/Uso : &#60;/b&#62;one&#60;/div&#62;&#60;div&#62;&#60;b&#62;5) Observación : &#60;/b&#62;two&#60;/div&#62;&#60;/div&#62;', '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"}

josemalena avatar Jan 31 '23 17:01 josemalena

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 ?

btry avatar Jan 31 '23 17:01 btry

Maximum time: 1 Day Escalation level: -1 day

josemalena avatar Jan 31 '23 17:01 josemalena

Thanks. I'll try to reproduce with these values.

btry avatar Jan 31 '23 17:01 btry

Hi, we've a similar problem, when we submit the form we receive this alert: image 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

joacoetche06 avatar Apr 19 '24 21:04 joacoetche06

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 ?

btry avatar Apr 22 '24 06:04 btry

Hi, we don't have any sql error related with this

joacoetche06 avatar Apr 22 '24 12:04 joacoetche06