How do I include a date field in a file name using "importFile" command?
I have a button on my form that when pressed, generates a new pdf file with a specific filename using information entered into the form. I almost have it how I want it, but for some reason I cannot get the 'Order Date' field to be included as part of the file name. How can I do this? This is what I think the code would look like:
importFile(this, printAndSaveRecord(this, "Invoice 3"), "Receipt-Unit-" + Assignments.Trucks.'Truck #' + "-" + Id + 'Order Date' + ".pdf")
As this is, it won't create a file, but it will create the file if I remove 'Order Date'. Any suggestions?
5 replies
-
Try
text('Order Date')
-
Hi Sean, thank you for the response. I tried it but no luck. I don't know if this could give us a hint to what's going on or not, but I noticed if the Order Date field is blank.... it will create a new pdf file, however, if there is a date inside the Order Date field, nothing happens and no file is generated.
-
Hi Jeremy, There are only 2 possible solutions I can think of at the moment. One is to build the entire string and assign it to a variable and then use the variable in the
importFile()
function, but I'm not very confident that will work. The other way is to create a Text field in your table for the purpose of storing that string once it's built and using the Text field inimportFile()
function. I'm fairly confident that will work. -
Thanks Sean! That helped and I've got it! Here's the code and it works!
let y := year('Order Date');
let m := month('Order Date');
let d := day('Order Date');
let myDate := m + "-" + d + "-" + y;
importFile(this, printAndSaveRecord(this, "Invoice 2"), "Receipt-Unit-" + Assignments.Trucks.'Truck #' + "-" + Id + "_" + myDate + ".pdf") -
Did your original date have slashes instead of dashes? That will definitely cause a problem
Content aside
- 4 yrs agoLast active
- 5Replies
- 1132Views