Question T7425
Visible to All Users

Survey Logic trigger only working on first question in Matrix (multiple choice)

created 3 years ago

Good Morning,

I have this trigger here:

{AddActivities} notempty and {HSE} notempty and {ServiceDelivery} notempty and {RateTheFollowing.Transportation.Rate} notempty and {RateTheFollowing.Time.Rate} notempty and {RateTheFollowing.Performance.Rate} notempty and {RateTheFollowing.OperatingProcedures.Rate} notempty and {RateTheFollowing.Interactions.Rate} notempty and {RateTheFollowing.EquipPrep.Rate} notempty and {RateTheFollowing.DailyComms.Rate} notempty

And if the trigger evaluates to true, it is supposed to set a question value that is just a single input to show the string 'Complete'

For changes to AddActivities, HSE, ServiceDelivery, and ANY Matrix FIRST question (In this case, it is RateTheFollowing.Transportation.Rate) seem to trigger a evaluation, but any question in the Matrix after the first question do not trigger an evaluation. To get it working, I have to change the question answers of the first four I mentioned above. Not sure if I am missing something here or if this is potentially a bug. Let me know if you have any questions. I have attached a copy of the survey in question. TIA

Answers approved by surveyjs Support

created 3 years ago

Hello Michael,
What is the goal? Do you want to set the value when all cells in matrix dropdown are set? If yes, then I suggest to write a custom function to deal with it.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (2)

      If the code can be generic then that could work. Basically all the values of the matrix should be truthy and the values of the 3 questions outside of the Matrix should be truthy. I posted the Survey Logic our client wrote out for that specific Survey. The trigger survey logic seems to work for the 3 questions outside of the Matrix and then the first question in the Matrix, but then it fails to continue looking at the rest of the survey logic for the rest of the Matrix questions

        Basically in short, the Survey Logic doesn't look at any of the Matrix questions except the first one listed in the Survey Logic

          Here is the example and here is the code of custom function:

          JavaScript
          var allCellsAreSet = function (params{     if(params.length < 1return;     var matrix = this.survey.getQuestionByName(params[0]);     var rows = matrix.visibleRows;     for(var i = 0; i < rows.length; i ++) {         var row = rows[i];         for(var j = 0; j < row.cells.length; j++) {             if(row.cells[j].question.isEmpty()) return false;         }     }     return true; }; //Register the custom function Survey     .FunctionFactory     .Instance     .register("allCellsAreSet", allCellsAreSet);

          Please note, we have to parse into function the question name, since we need the question instance and not the question value.

          Thank you,
          Andrew
          SurveyJS Team