Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#785582
I am using ProcessMaker 3.0.1.8-community and trying to generate a dropdown list in a grid based on the value set in another column in the grid.
If the value is 10 for example, the column with the dropdown (select) control is modified to have 10 options.
The generating of the options works and when the form is submitted, I can see the selected value in the grid array. However, when the form is loaded, the selected value is reset to null and does not show as selected on the form.

How can I get the selected value and set it when redisplaying the form?
Code: Select all
function setDropDownSelect(gridId, prefix) {
    var aGridVals = $('#'+gridId).getValue();
    //loop through grid and get the value for staffScore and maxScore on each row
    for (var i = 1; i <= aGridVals.length; i++) {
      var currValue = aGridVals[i-1][4];
      console.log(gridId + ' --- ' + i + ' --- ' + aGridVals + ' --- ' + currValue);
      var maxScore = $("#form\\[" + gridId + "\\]\\[" + i + "\\]\\[" + prefix + "_maxScore\\]").val();
      var selector = "select#form\\[" + gridId + "\\]\\[" + i + "\\]\\[" + prefix + "_staffScore\\]";

      
      //$(selector).append('<option value="">Select</option>'); //set empty selector
      for (var j = 0; j <= maxScore; j++) {
        if( j == currValue ) {
          $(selector).append('<option selected="selected" value="' + j + '">' + j + '</option>');
        }
        else {
          $(selector).append('<option value="' + j + '">' + j + '</option>');
        }
      }
    }
}

function initialize() {
  setDropDownSelect('peopleManagement','pmg');
  setDropDownSelect('financialSoundness','fsg');
  setDropDownSelect('globalness','gg');
  setDropDownSelect('productQuality','pqg');
  setDropDownSelect('serviceQuality','sqg');
  setDropDownSelect('innovation','ig');
  setDropDownSelect('community','cg');
}

initialize();
Every help will be greatly appreciated.
#785584
The problem is that when you redisplay the form, the dropdown box doesn't have the list of options which you added with JavaScript. One solution is to save those additional options in a JSON string in a hidden field. Add a trigger which is fired after the DynaForm which will use json_decode() to read the contents of the hidden field and then add any additional options to a PM Table. Then use a database query in the PM Table to populate the dropdown box.

The other way to handle this is to use a suggest box instead of a dropdown box so it can accept values which aren't in the list of accepted options.

Fildena double 200 mg capacity to move the relaxin[…]

Wat is Fildena Double 200?

Fildena double 200 mg capacity to move the relaxin[…]

💥 Join the Exclusive Trading Community and Experie[…]

Briefly introduce the topic and provide context. S[…]