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

Question

Question

Pre-Populate the First Row of a Collection in a New Form

asked on March 9, 2022

I have a new form. In that form, I have a collection with two fields:  (1) SDS Type, and (2) Upload button. The SDS Type field defaults to "Supplier Document" so that anytime a row is added, it shows as Supplier Document. How would I go about adding the first row of a collection and setting the value of the SDS Type to "Supplier Transmittal" when a brand-new form/process opens:

This would require the user to upload the PDF of the transmittal and one or more Supplier Documents. Trying to dummy-proof so the user doesn't make the wrong choice. I also need to know which is the transmittal and which are the supplier docs. This is what I had, but it didn't work.

$(document).ready(function(){

//Prefill Row 1 with SDS Type = Supplier Transmittal
  $('#Field54-1 input').val('Supplier Transmittal');

})  //close document.ready

Maybe I need to add a row first? I've seen solutions where rows can be added on various actions, but I haven't seen on open.

0 0

Answer

SELECTED ANSWER
replied on March 10, 2022

Hi Gloria,

You're very close with your code, however because the field is a drop down rather than a text box you'll need to use a slightly different way to set the value of the field. In the below example I have added a class called "document-type" to the drop down field in my table.

$(document).ready(function(){
  $('.document-type select:first option[value="Supplier Transmittal"]').prop('selected', true);
});

Hope this helps!

Dan

1 0
replied on March 10, 2022

Thanks for the responses Troy and Daniel! Daniel's response solved the issue.

0 0

Replies

replied on March 9, 2022

Hi Gloria,

 

Unless I'm misunderstanding the question, as long as the collection as the minuim # of rows set to 1 you will always start with 1 Row in the collection on form load.

 

If the minium is set to 0 then you won't have any row in the collection on Form load.

As for the defaults, make the default on the drop list and make the upload required.

 

Here is an example: https://portal.laserfiche.com/f6288/forms/test

or am I totally misunderstanding your question?

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

Sign in to reply to this post.