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

Fix salesagility#10629 - Duplicating Surveys #10632

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from

Conversation

SinergiaCRM
Copy link
Contributor

@SinergiaCRM SinergiaCRM commented Jan 28, 2025

PR closed #9498

Closes #8947

As the Issue mentions, there is a problem when duplicating Surveys. Basically, what goes wrong when duplicating:

  • If the base survey has questions and no answers, the duplicated survey will take all the questions, leaving the base survey without questions
  • If the base survey has questions and answers, the duplicated survey won't take/keep the questions, neither the answers. Although the Editview that appears after duplicating will contain the questions and won't allow it to modify them:
    Selection_430

Closes #10629

Having a WorkFlow and duplicating a survey or create also duplicated the questions, as the code was executed without any workflow verification. This was because:

  • When duplicating survey X to Y or creating survey X, having WorkFlow active, the code saved the questions normally.
  • But because there was no control over the workflow, when the workflow was executed:
    • The code re-executed the foreach loop that saves the questions.
    • As a result, the questions were saved twice: once during the normal save and once during the workflow execution.

Description

This PR fixes the Duplicate functionality for the Surveys module, as we understand it should work:

  • If the base survey has questions and no answers, the duplicated survey will keep the questions, duplicating them.
  • If the base survey has questions and answers, the duplicated survey won't will take/keep/duplicate the questions or but not the answers. And other new Questions can be added during the first edition after duplication.
  • Fixed the workflow problem by adding a control variable already_saved which is used to verify that the method is not re-executed. If already_saved is set, it means that the method has already been executed and reprocessing of the questions is avoided.

Motivation and Context

With this change, duplicating Surveys will be consistent.

How To Test This

1- Create a Survey
2- Add questions
3- Duplicate it.
4- Repeat adding answers to the survey.

Workflow Issue

  1. WorkFlow Module: Surveys
  2. Run: Only On Save
  3. Run On: New Records
  4. Action:
    4.1. Modify the survey itself, for example, change from draft to published status.
    4.2. Calculate fields, for example, calculate the name.
  5. Duplicate the survey from step 1, checking the number of questions it has.
  6. Check that the survey has been duplicated without duplicating the questions and that it has the same questions as the survey from step 1.
  7. Create a survey with several questions and check that the surveys are not duplicated.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant