Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incidencia - Encuestas - Al duplicar una encuesta se duplican las preguntas en la encuesta duplicada #91

Open
ManuSinergiaCRM opened this issue Jan 29, 2024 · 1 comment · May be fixed by #483
Assignees
Labels
bug Something isn't working Encuestas not urgent

Comments

@ManuSinergiaCRM
Copy link
Collaborator

ManuSinergiaCRM commented Jan 29, 2024

Descripción del problema
Se comprueba que si tenemos un FdT:

  • Módulo base: Encuestas
  • Ejecutar al guardar
  • Registros nuevos
  • Acción:
    • Modificar la propia encuesta, por ejemplo, pasar de estado borrador a publicado.
    • Calcular campos, por ejemplo, calcular el nombre.

Al duplicar una encuesta, en la encuesta duplicada tendremos también duplicadas las preguntas.

Preguntas de encuesta duplicadas

Información

  • No he podido probarlo en la versión 7.12.12 de SuiteCRM ya que al ir al commit de dicha versión no funciona y no he podido investigar que sucede.
  • En SuiteCRM 7.14.2 no se reproduce la incidencia.
@AlbertoSTIC
Copy link
Collaborator

if (($_POST["duplicateSave"] && $_POST["duplicateSave"]="true"))
{
unset($_REQUEST['survey_questions_ids']);
}
// STIC End
$res = parent::save($check_notify);
if (empty($_REQUEST['survey_questions_supplied'])) {
return $res;
}
foreach ($_REQUEST['survey_questions_names'] as $key => $val) {
if (!empty($_REQUEST['survey_questions_ids'][$key])) {
$question = BeanFactory::getBean('SurveyQuestions', $_REQUEST['survey_questions_ids'][$key]);
// STIC-Custom 20211110 AAM - With deleted questions, call mark_deleted and skip the loop
// STIC#457
if ($_REQUEST['survey_questions_deleted'][$key]) {
$question->mark_deleted($question->id);
continue;
}
// END STIC
} else {
$question = BeanFactory::newBean('SurveyQuestions');
}
$question->name = $val;
$question->type = $_REQUEST['survey_questions_types'][$key];
$question->sort_order = $_REQUEST['survey_questions_sortorder'][$key];
$question->survey_id = $this->id;
$question->deleted = $_REQUEST['survey_questions_deleted'][$key];
$question->save();
// STIC-Custom 20211110 AAM - Removing the "s" from the word question(s)
// STIC#457
// if (!empty($_REQUEST['survey_questions_options'][$key])) {
// $this->saveOptions(
// $_REQUEST['survey_questions_options'][$key],
// $_REQUEST['survey_questions_options_id'][$key],
// $_REQUEST['survey_questions_options_deleted'][$key],
if (!empty($_REQUEST['survey_question_options'][$key])) {
$this->saveOptions(
$_REQUEST['survey_question_options'][$key],
$_REQUEST['survey_question_options_id'][$key],
$_REQUEST['survey_question_options_deleted'][$key],
$question->id
);
}
}
return $res;

Seguramente este código sea el causante de duplicar las preguntas. Se debería ver qué condición se podría aplicar/eliminar para que no ejecute dos veces la función.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Encuestas not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants