Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality

Moderator: amosbatto

Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By JarodC
Hi, I have a standard scenario where I'm using a dropdown to select a record filled from an underlying array, but I can't see how you fill the associated text boxes on change.

The datasource is an external app accessed via service call rather than sql so can't use that.

I can't see how the 'array variable' datasource works for dependent record fields/text boxes, or can this be done through javascript?

Any help appreciated?

To achieve your requirement, please do the following:

1. Create a trigger which assigns value to an array variable which in turn is json encoded and assigned to an hidden field in the Dynaform. The trigger can be something like this:
Code: Select all
$arr =  array(
			  array('1', 'a'),
			  array('2', 'b'),
@@hdn = json_encode($arr);
2. Assign this trigger before Dynaform.
3. In the dynaform take a hidden field with ID @@hdn.
4. In the Dynaform write the following javascripts:

1. populatearray:
Code: Select all
var aProducts = eval(getValueById("hdn"));
if (typeof(aProducts) == 'object' && aProducts.length) {     //if an array
   for (var i=0; i < aProducts.length; i++) {
      var opt = document.createElement("OPTION");
      opt.value = aProducts[i][0];
      opt.text = aProducts[i][1];
2. changetextval:
Code: Select all
var changeDrop = function () {
    var idx = getField("dd1").selectedIndex;// name of the dropdown
    var selectedValue = getField("dd1").options[idx].value;
    getField("text1").value = selectedValue;
 var dynaformOnload = function() { // calling the function
    leimnud.event.add(getField('dd1'), 'change', changeDrop );
where dd1 is the ID of dropdown and text1 is the ID of text box which is the dependent field on dropdown.
This sets the value of the textbox as the value of the option selected in the dropdown.

Hope this helps.

Best Regards

The ID in your @@supervisorId variable is probably[…]

What version of PM are you using? You should use a[…]

First of all, do you know PHP and JavaScript? If […]

Force Skin

When you set the User Experience to "Switchab[…]