Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Hi, I was unable to locate a way to dynamically add options to a checkgroup control using Javascript.
I'm trying to add specific group UIDs and group names to the options.
Right now, I'm adding them through the UI on the front end, but I like to avoid using hardcoded UIDs whenever possible.
Last edited by richvle on Mon Nov 12, 2018 1:58 pm, edited 1 time in total.
If you are using PM 2.X, then you can use this JavaScript code:
Code: Select all
function removeCheckgroupOption(checkgroupId, constantOptionValue, optionValueToRemove) {
  //use the value of an option in the checkgroup that will always exist
  var aNodes = getField(checkgroupId+"]["+constantOptionValue).parentNode.childNodes;

  if (aNodes.length == 0) {
    alert("removeCheckgroupOption() error:\ncheckgroupId '"+checkgroupId+"' or constantOptionValue '"+constantOptionValue+"' does not exist.");
    return -1;

  //find the option in the list that you want to delete:
  for (i = 0; i < aNodes.length; i++) {
    if (aNodes[i].id == "form["+checkgroupId+"]["+optionValueToRemove+"]") {
      //remove <BR>:
      //remove span and its child label:
      //remove input type=checkbox:
      return 0;
  //for some reason this is still executing, even when the optionValueToRemove exists:
  //alert("removeCheckgroupOption() error:\nOption '"+optionValueToRemove+"' does not exist.");
  return -2;

removeCheckgroupOption("selectServices", "accounting", "catering");

function appendCheckgroupOption(checkgroupId, constantOptionValue, newOptionValue, newOptionLabel) {
  var newOptionHtml = '<input id="form['+checkgroupId+']['+newOptionValue+']" pmfieldtype="checkgroup" '+
    'name="form['+checkgroupId+'][]" value="'+newOptionValue+'" type="checkbox">'+
    '<span class="FormCheck"><label for="form['+checkgroupId+']['+newOptionValue+']">'+newOptionLabel+'</label></span><br>';
  getField(checkgroupId+"]["+constantOptionValue).parentNode.innerHTML += newOptionHtml;

appendCheckgroupOption("selectServices", "accounting", "mafia", "Corporate warfare");
Here is a sample process to test it:
(8.25 KiB) Downloaded 28 times
Thanks Amos. I tried option 3 using JavaScript to modify the model information for the field, but wasn't having luck. So I tried doing it using the datasource = array variable method as mentioned in ... Datasource and was able to get it to work.
Code: Select all
$groupName01 = "IV Requestor";
$groupLabel01 = "Access To Submit Invoice Vouchers";
$groupId01 = PMFGetGroupUID($groupName01);
if (empty($groupId01)) { 
  throw new Exception("Group '$groupName01' doesn't exist."); 
$groupName02 = "VR Requestor";
$groupLabel02 = "Access To Request New OR Update Existing Vendors";
$groupId02 = PMFGetGroupUID($groupName02);
if (empty($groupId02)) { 
  throw new Exception("Group '$groupName02' doesn't exist."); 

@=RequestTypeOptions = array(
  array($groupId01, $groupLabel01),
  array($groupId02, $groupLabel02)

Hi, I have a case which the duties of the users ar[…]

Starting subprocess

Can we start multiple instances of a sub process. […]

mobile app source code

ProcessMaker Mobile App Android, Use out-of-the-bo[…]

Timer does not works

Hi guys, I'm completely new to process maker. Rece[…]