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

Question

Question

Passing contents of a collection via a URL

asked on November 16, 2017 Show version history

Is there a way to pass the contents of a collection between two forms as parameters in a starting URL?

 

Thanks

1 0

Replies

replied on November 16, 2017

Hi Ken,

See here

Only fields outside of collections and tables can be populated via parameters. Address, radio button, checkbox, file upload, and signature fields cannot be populated in this way.

0 0
replied on November 16, 2017

Hi Tri,

Despite what the help doc says on this, I was able to prefill radio buttons and check boxes with the help of posts from others using Java. For example : https://answers.laserfiche.com/questions/86912/Prefill-Checkbox-with-selected-values-via-URL#86933

I can't seem to find anyone posts where others have been able to prefill collections using Java yet.

 

Thanks

1 0
replied on November 17, 2017

Yep, this works. It's also useful for augmenting the field lookup function, which won't populate tick boxes and radio buttons.

0 0
replied on November 17, 2017 Show version history

Ken,

I was answering the question of whether it was supported directly with URL parameters. You could certainly use JavaScript to pass basically anything from one thing to another, e.g. radio buttons, as in the post you linked.

Here's a simple example of passing single line field values in a collection into a hidden field, whose value is passed into a URL of a different form. 

$(document).ready( function() {
  // Declare variables
  var count = 1; 
  var arraySL = [];
  
  // Determines amount of rows in original collection
  function updateCount () {
    var count = document.getElementsByName("q3").length; //q3 is a single line in the collection
	$('.count input').val(count);
  }
  
  $('.collection .cf-collection').on('click', '.cf-collection-delete', updateCount);
  $('.collection .cf-collection-append').on('click', updateCount);

  // On Form submission, read and push all the values into their respective arrays
  $('.Submit').on('click', function (){
    for (var i = 0; i < $('.count input').val(); i++) {
      n = i + 1;
      arraySL.push(document.getElementById("Field3(" + n + ")").value);
    }
    alert(arraySL);
    $('#q7 input').val(arraySL); // single line collection field that is hidden and passed as URL
  })
});

On form submission, all of the values inserted into the single line fields are pushed to an array. It also keeps count of how many rows are in the collection.

In the second form, you pass over the row count and the array. Use JavaScript to set the number of rows, and split out the array and insert them into their proper fields. The code above should give you running start for that, you're just trying to do the opposite. (Instead of reading the collection and pushing it into the hidden fields, you're reading the hidden fields and pushing into the collection.)

2 0
replied on November 24, 2017

Thanks Tri!

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

Sign in to reply to this post.