You are viewing limited content. For full access, please sign in.

Question

Question

Checkbox labels changed in JavaScript not saving to repository

asked on August 19, 2021

We are dynamically changing our checkbox labels in JavaScript, however those changes are not saving to the repository. The dynamic labels are pulled from a LookUp and saved to a Multi-Line field in a prior step in the process.  Then I pull those into an array and use that to change the checkbox labels.

Does anyone know how to get the new labels to show up on the copy saved to the repository?

The code that changes the values

  var myArray = $('.hiddenCheckboxLabels textarea').val().split('|');
  var arrayLength;

  arrayLength = myArray.length;
  
  var checkboxIndex = 0;
  $('.departmentCheckboxes .choice label').each(function() {
    $(this).text(myArray[checkboxIndex]);
    checkboxIndex++;
  })

 

What the form looks like before submitting

 

What gets saved in the repository

0 0

Replies

replied on August 19, 2021

What are your save to repository settings? Are you saving the submitted form from that user task? Or are you using the form with current data? 

Also, are you seeing these JS label changes if you view the submitted form on the thank you page or the completed submission in monitor? 

1 0
replied on August 19, 2021

I have it set to " Save a form with current process data" and using the form in the current step (this is a step after the initial submission).  and when I look at the submission monitor it does not show the new labels.

0 0
replied on August 19, 2021 Show version history

EDIT: I think that's because after submission, the multi-line field is no longer a textarea so your line 1 cannot pull that value. You'll need to update your JS so that if it can't pull the value from the editable textarea, it tries to pull it from the read-only multi-line. You can test this by setting the form to read-only and ensure the JS works. 

(sorry was mixing up cloud and self-hosted, this answer is better)

3 0
replied on August 19, 2021

Two things: 

1. We don't run JS when saving a form to the repository using current data. You'll need to set it to save a form from a previous step and select the user task of the submission. Those images are generated using the JS run during runtime. 

2. The above will save the same form you see after submission or from the monitor page (which you said didn't work). I think that's because after submission, the multi-line field is no longer a textarea so your line 1 cannot pull that value. You'll need to update your JS so that if it can't pull the value from the editable textarea, it tries to pull it from the read-only multi-line. You can test this by setting the field to read-only and ensure the JS works. 

replied on August 19, 2021

Two things: 

1. We don't run JS when saving a form to the repository using current data. You'll need to set it to save a form from a previous step and select the user task of the submission. Those images are generated using the JS run during runtime. 

2. The above will save the same form you see after submission or from the monitor page (which you said didn't work). I think that's because after submission, the multi-line field is no longer a textarea so your line 1 cannot pull that value. You'll need to update your JS so that if it can't pull the value from the editable textarea, it tries to pull it from the read-only multi-line. You can test this by setting the field to read-only and ensure the JS works. 

replied on August 19, 2021

What is the difference between a 'multi-line' and a 'textarea'? I thought they were the same, just one is what it's called in the GUI side when you drag and drop it onto your form and then you use "textarea" in the javascript to get the value.

0 0
replied on August 19, 2021

I will be running more testing tomorrow to double check, but I think I got it working by doing the following code.

I really appreciated your help in trying to get this working. 

 

  var myArray = [];
  var stringForArray;
  
  
  
  if($('.hiddenCheckboxLabels textarea').length == 1)
  {    
    stringForArray = $('.hiddenCheckboxLabels textarea').val();           
  }
  else
  { 
    stringForArray = $('.hiddenCheckboxLabels div.ro').text();
  };
  
  myArray = stringForArray.split('|')
   
  
  
  var checkboxIndex = 0;
  $('.departmentCheckboxes .choice label').each(function() {
    $(this).text(myArray[checkboxIndex]);
     checkboxIndex++;
  }); 

 

0 0
replied on August 20, 2021

I have more questions about around using lookups to set a checkbox lists labels. Here is the link to that post: https://answers.laserfiche.com/questions/191109/setting-checkbox-labels-based-on-lookup--does-anyone-know-a-better-way

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.