Dear Folks!
I apologize in advance. I really searched but didn’t find anything in the forum.
Here is my problem:
In my tapforms-CRM I have a button, that generates an email to the customer when clicked. Indeed, I managed, that this generates a complete addressed email with subject and text. I have also a button for phone calls. (I love tapforms for this!)
Now I would like to have a button, that prints the invoice (from the invoice-layout) or saves it as a PDF.
Of course, I know: I could just go to the invoice-layout and then choose menue>print. But I’d rather have it as a button in the CRM-layout.
Really great would it be, if there could be a script, that could be used to generate an email containing the invoice PDF as an attachment.
Thanks in advance for thinking along.
Regards,
EDDY
You can use scripting to build something like this today with the prompter and a saved search.
Create a new saved search with the criteria that you’re interested in and then you can use this to create a prompter with just the options and set the field from there. It’s not as transparent in the UI and does require executing a form script but it does give you some of the same functionality.
I’ve been trying to find a good example on the forum but don’t see one, I don’t think I have a video on it either. Might be something for the backlog.
Bingo! All it took was a decent night’s sleep before I noticed that the id was staring me in the face on the Fields panel and that I could just cut and paste it into the script.
It barfed on TIF files for some reason but I can convert these.
Thank you for your patience and assistance.
Just set the field ‘Image name’ as a script and copy my code in there and adjust the photo_id according to your form.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Daphne,
The Field Script that Daniel wrote for you does exactly what you describe.
Did you adjust the photo_id value in the script to match up with the ID of the Photo field in your own form?
When you said it didn’t work for you, what exactly happened? Were there any error messages in the console log?
Thanks,
Brendan
Thanks for your reply. I am unable to get it to work and I may not have described my problem well enough. Please bear with me.
I am creating my PDF by using the Print menu to save a PDF of a selection of database fields to a file on my system. This file, plus a copy of the images directory my database references, will be written to a flash disc and sent by post to someone. The person can then peruse the PDF and refer to the images if they wish. There may not be an image associated with every record, so the script must be able to cope with that.
Where a record does have one or more associated images my field called “Image” shows the image(s). I wish to set up a new field in each record (let’s call it “Image name”) which shows the filename of the image(s) (just the filename not the complete path). I can then include “Image name” on my printout so the recipient knows which filename to look at.
Does that make it clearer?
I assume that all your PDFs are either file attachments or photos. This field script extracts the filenames and returns them as a comma separated list.
You would need to adjust the photo_id field according to your form. Just get the id of the file attachment or photo attachment field.
function Get_Filenames() {
const photo_id = 'fld-xxx';
let filenames = []
let photos = record.getFieldValue(photo_id)
console.log("Found photos:" + JSON.stringify(photos));
for (photo of photos){
filenames.push(photo.filename);
}
return filenames.join(', ')
}
Get_Filenames();
-
This reply was modified 3 years, 10 months ago by
Daniel Leu.
-
This reply was modified 3 years, 10 months ago by
Daniel Leu.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Justin,
Can you please include your Inventory Parts and Customer forms too? They weren’t included within the Service-Order form.
When I look at the List formula, all I am seeing is: /(1-.30). Perhaps it didn’t come through in the archive or maybe it was just like that in the original. Not sure.
I would also prefix the .30 with 0. So (1 - 0.3). The trailing 0 is insignificant and not required.
For reducing the inventory quantity you would have to add a Field Script that gets the value of the Qty field and then looks up the part from the Inventory Parts form and then subtracts the value from there. It would take a bit of work.
Thanks,
Brendan
Working on a service order database with a live inventory. I am new too scripting and am just starting to do the basics. I have created this database without scraping, I wouldn’t mind adding it but just don’t know enough. So… with that said if the answer to my question lies within scripting than I will have a bunch of questions. I currently have 2 issues that I am sorting out at the current moment, any help would be greatly appreciated.
First issue,
I have created a form called “Inventory Parts” that I have entered information on an Item. Things like: Part #, Name, Price, Qty in stock. then I have created another form called “Service Order” which has a table that copies records from “Inventory Parts” form. I have created another field in the table that has the copied data that I have named QTY. Then I created another field that I called “Sub Total” that contains a formula (Qty*List). When using the copied data in the field and using the formula the copied List price turns to $0.00 and I am unable to use the expression to fill the sub total.
Second issue,
I can’t for the life of me figure out how to reduce the inventory qty after the part is added to a service order.
Thanks in advance, I have tried paid programs and can’t seam to find what I want. This is why I have moved to building my own through tap forms.
Attachments:
You must be
logged in to view attached files.
In the script editor, make sure the return type is set to be a number in addition to the number format setting in the field settings. The default for script fields is text.
Alternatively if you click the ID button on the Script Editor, you’ll get a variable assigned to the Field ID of the selected field. Then you can use that in the getTotalOfField() function.
I prefer to see the Field IDs as separate things because when you look at the code it’s hard to see what field you’re getting the total from.
For example:
var order_cost_id = 'fld-acdbf6132877436d8f86d12a7a732a13';
var order_cost_total = form.getTotalOfField(order_cost_id);
I know it’s two lines instead of one, but it’s easier to read then.
Create a new script field, delete all of the boilerplate it creates and then double click on the field you want to total, it should look like this:
var order_cost = record.getFieldValue('fld-acdbf6132877436d8f86d12a7a732a13');
Delete the text before record.getFieldValue and replace it with form.getTotalOfField, it should look like this:
form.getTotalOfField('fld-acdbf6132877436d8f86d12a7a732a13');
The exact text of the fld- stuff will be different based on your actual field.
I think you’d need to set the value of the fields referenced by the calculation field because otherwise a recalc will reset the field value anyway. I wonder if there is some sort of data race between setting the value and then the record creation triggering the calc/script fields to be run as well. That would work ok for calculation fields for the composite key use case but I can see if someone joined on a script field that might be a little more challenging as well.
Would it make sense to block the UI if someone uses a calculation or script field in a JOIN?
It might still be creating the blank record but when it loads in the list view that record is excluded because a blank record likely doesn’t meet your JOIN criteria because it’s Lot # field isn’t set. When you’re in the list of linked records, the new record button works because TF hasn’t recalculated the record list yet, it is just inserting the newly created record into the view. Though when this happens if a recalculation happens, that record will disappear from the list if it doesn’t satisfy the JOIN field criteria.
Ideally if you want to use TF to create the records then the JOIN type really isn’t a good fit as you have to manually ensure the correct value is set. JOIN is great for piecing together externally linked data though. One other workaround I personally use is a script that creates linked records with the correct values set for the link to work properly (important when using calc fields to JOIN on composite keys).