Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
November 22, 2019 at 1:43 PM #38188
In reply to: Displaying linked fields
Brendan
Keymaster@Martin, that’s where the power of Scripting comes in. You can build scripts that expose the data further up the relationship chain from lower down. Although in general that’s a read-only thing. I agree though, it would be nice to be able to put editing controls in Tap Forms from anywhere down the relationship hierarchy. Doesn’t mean I’ll ever build that. But I understand the desire.
November 22, 2019 at 8:07 AM #38178In reply to: Table row index number
Sam Moffatt
ParticipantI think the challenge is with a table field, the calculation field only displays the fields from the record context. If you try to copy a field placeholder from a parent calculation field into the table calculation field then it doesn’t save right. If you create a script field in the table, when you insert the fields in the editor it includes the index format (e.g.
table_field_name[index]) andrecordin that scope is still the main record,getFieldValuefor fields in the parent form work but don’t work for fields in the current row of the table.At least in my testing, I couldn’t figure out how to get it to behave correctly.
November 22, 2019 at 1:25 AM #38169In reply to: Table row index number
Brendan
KeymasterHi Stephen,
I don’t think you need to index into this. Is your goal to do that simple multiplication, then all you need to do is add a Calculation field to your form that multiplies your Minutes field by your Hourly_Rate field.
You can also do it in a script:
function Cost() { var minutes_id = 'fld-abcd1234...'; var hourly_rate_id = 'fld-1234abcd...'; var minutes = record.getFieldValue(minutes_id); var hourly_rate = record.getFieldValue(hourly_rate_id); return minutes * hourly_rate; } Cost();The value of
recordwill be the current record in the Table field.November 22, 2019 at 1:16 AM #38168In reply to: Table row index number
Sam Moffatt
ParticipantOk, so I had to read this a few times and I’m still not sure I understand correctly but I did do some testing. I think you’re trying to calculate a cost based on the value in the table field and a value in a field outside of the table field?
I tried figuring out how to do this myself with a script field and couldn’t get it to work. I can sort of do it in a calculation field but only with fields from within the table. I might be missing something obvious, maybe I need to look later.
If you’re willing to restructure a little, I think you can do what you want a little easier with a Link to Form field though the script/calculation field in the table should be able to do that.
November 22, 2019 at 1:14 AM #38167In reply to: Generating eMails with attachments
Brendan
KeymasterThere’s no functionality for attaching a file to an email from within a Script.
However, on the iOS version, when you email a record, Tap Forms will include all photos and file attachments as attachments to the email. That functionality doesn’t exist on the Mac version though.
November 21, 2019 at 9:43 PM #38163Daniel Leu
ParticipantThis should be possible. I don’t see any reason why not.
Sam has a smart script to copy a record from one form to another. Copying from one table to another is very similar. Have a look at his script for inspiration: https://www.tapforms.com/forums/topic/script-to-copy-records-from-one-form-to-another/
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 21, 2019 at 7:44 PM #38159In reply to: Feature suggestion: connecting databases
Daniel Leu
ParticipantHi Courtney,
Instead of using export and import, a script could be used to capture all the new data and copy it to the clipboard using
utils.copyTextToClipboard(). Then in your main document, you could have a second script that gets this data usingutils.copyTextFromClipboard()to create the new technicians records.JSON.stringyfy()andJSON.parse()would be used to convert your captured data object into a string and to decode it again.If you want to follow this route, have a look at Sam’s elegant script where he copies data from one form to another without defining the fields: https://www.tapforms.com/forums/topic/script-to-copy-records-from-one-form-to-another/.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 21, 2019 at 4:06 PM #38158Ron Kline
ParticipantHas anyone used script to copy the contents of a table field in one form to a table field in a linked form? Is it even possible?
November 21, 2019 at 9:39 AM #38154In reply to: Displaying linked fields
Daniel Leu
ParticipantIdeally it would be nice to show the actual field so that you could edit it.
Ahh… you want to edit the field at the same time? Just like that it’s not possible. You would need a helper script that copies edited code back to the child field.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 21, 2019 at 6:27 AM #38151In reply to: Table row index number
Stephen Abshire
ParticipantThanks for the reply you are quite helpful. While I do have a development background TapForms and JavaScript are new to me. Let me try with a photo so it may help out a bit.
Looking at the attached image with a table field named ‘Timeline’ I want to do the following:
Cost = Minutes * Hourly Rate (not pictured)
The ‘Timeline’ field seems to be an array of records (rows) and what I need to figure out how to do is get the array index for the currently selected row. JavaScript I believe has zero-based arrays so the index for the current row would be something like Timeline[7]. What I don’t know how to do is get the array index for the current row so that I can get the values to do the math. A crude pseudo-code may be like this:
Timeline[index].Cost = Timeline[index].Minutes * Hourly_Rate
So how do I determine what ‘index’ is or is there a different way to do this?
Attachments:
You must be logged in to view attached files.November 21, 2019 at 5:44 AM #38150Topic: Generating eMails with attachments
in forum Script TalkEddy
ParticipantHi Folks!
We are using TapForms also as a CRM-System.
Therefore we let TapForms generate Emails for us. We are using a script, that generates a “mailto” phrase including address, subject and body. This headers are collected from TapForms fields. This works great.
And here is the task:
Sometimes we have to send our clients/guests a PDF (standard contract-template, checklist etc.). Of course, we store these standard PDFs in our CRM-System, i. e. TapForms. But there is no way to generate an email with an attachment by using the “mailto”-method.
What we need is a button inside a form, that creates an email with an attached file, coming out of a attached-file-field.
Any ideas?
Thanks in advance, Eddy
November 21, 2019 at 2:54 AM #38147In reply to: Displaying linked fields
Martin Inchley
ParticipantThis technique, of course, doesn’t show the actual field you are referencing. It just gets its contents into a script field in the current form.
Ideally it would be nice to show the actual field so that you could edit it.
November 20, 2019 at 7:09 PM #38137In reply to: Table row index number
Sam Moffatt
ParticipantThe challenge with both table fields and the many side of link to form fields is that the ordering can change and is dependent upon the sort settings in the UI. What I ended up doing with my order items form (line items in an order) is use a script to set the line number:
var title = record.getFieldValue('fld-39ca9564ef2347ac93f933bc9a2316ac'); var order = record.getFieldValue('fld-c3a6725d7d9446da92bbb880ffe90a9e'); var order_items = order.getFieldValue('fld-9db0c7698499435ab6b18b7eb420e0ae'); var quantity = record.getFieldValue('fld-39379cdff743496f9a1ccbdc1ae56297'); var line_number = record.getFieldValue('fld-f95b68d488cb4b058bbf3de84e1a7c3b'); var note = record.getFieldValue('fld-d0cfab9ec09d497294fbd8b5b52caf16'); if (!line_number) { record.setFieldValue('fld-f95b68d488cb4b058bbf3de84e1a7c3b', order_items.length); console.log('Setting line number to ' + order_items.length); }This generally works ok, it’s not perfect, but sets a field in the form that I can then refer to later. I use this in particular to ensure that I can always get the correct order of line items for display.
November 20, 2019 at 4:50 PM #38136In reply to: Displaying linked fields
Daniel Leu
ParticipantScript fields are very powerful vehicles to fetch, format, and process data from different forms, among others.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 20, 2019 at 4:41 PM #38135In reply to: Displaying linked fields
Martin Inchley
ParticipantThat’s very helpful, Daniel. Because I came to Script Fields after first experimenting with Form scripts and the TapForms JavaScript API, I have up until now been using them to achieve an action rather than present a result.
-
AuthorSearch Results