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

Question

Question

Auto populate a field with the file name

asked on June 2, 2023

Hi. I have a table with a file upload. I would like to retrieve the file name when the file is uploaded.

0 0

Replies

replied on June 5, 2023

Hello, I haven't done uploods in a table, but on a normal upload, the filenames do show up in the variables.

 

0 0
replied on June 5, 2023

The vars in the table rows can also be accessed as variables in a workflow and template. But you would have to probably have another step in your forms process to pass the name of the file into a field in a table row.

 

0 0
replied on June 5, 2023

Hi Cris, if you would like to retrive the file name right after you upload it on the fill form page, you can refer to custom scripts in this post: https://answers.laserfiche.com/questions/144900/File-Upload-Name-Change

0 0
replied on June 6, 2023

Thanks. I've tried, but it didn't work for a table.

0 0
replied on June 6, 2023

It need to be modified to work in table, here is an example:

 

$(document).ready(function () {
  function fileOnChange(event) {
    var filename = $(event.target).val().split('\\').pop();
    $(event.target).closest('tr').find('.name-field input').val(filename);
  }
  $('.file-field input').on('change', fileOnChange);
  $('#q4 .cf-table-add-row').click(function() {
    $('.file-field input').off('change', fileOnChange);
    $('.file-field input').on('change', fileOnChange);
  });
})

#q4 is the table field id, and this part is needed if you want to handle newly added rows in table; file-field need to be added as classname to file upload field, and name-field need to be added as classname to the file name field.

0 0
replied on July 16, 2024

Hello, 

So happy to have found this post.  I was able to duplicate this in Classic Forms Designer and get it to work for me (which was a big relief), however the form I need the functionality in is in the New Forms Designer.  I do not seem to be able to get this to work in New Forms Designer.

I was able to use the q# in the Classic Designer, those are not present in the New Designer (at least not where I can see them).  I have tried many variations of Field ID and Var ID in place of the q#.  To no avail.  Can anyone help provide an example of this solution customized for the New Designer, with screenshots?  

Thanks in advance.

Christine

0 0
replied on July 17, 2024

Hi Christine,

Such javascript code is not able to work with the new forms designer, I'd recommend you how to use the JS functions of the new designer from here

https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Default.htm#../Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm?Highlight=LFForms

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

Sign in to reply to this post.