Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,191 through 2,205 (of 2,987 total)
  • Author
    Search Results
  • #38188
    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.

    #38178

    In reply to: Table row index number

    Sam Moffatt
    Participant

    I 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]) and record in that scope is still the main record, getFieldValue for 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.

    #38169

    In reply to: Table row index number

    Brendan
    Keymaster

    Hi 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 record will be the current record in the Table field.

    #38168

    In reply to: Table row index number

    Sam Moffatt
    Participant

    Ok, 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.

    #38167
    Brendan
    Keymaster

    There’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.

    #38163
    Daniel Leu
    Participant

    This 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&tricks

    #38159
    Daniel Leu
    Participant

    Hi 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 using utils.copyTextFromClipboard() to create the new technicians records.

    JSON.stringyfy() and JSON.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&tricks

    Ron Kline
    Participant

    Has 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?

    #38154
    Daniel Leu
    Participant

    Ideally 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&tricks

    #38151

    In reply to: Table row index number

    Stephen Abshire
    Participant

    Thanks 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.
    #38150
    Eddy
    Participant

    Hi 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

    #38147
    Martin Inchley
    Participant

    This 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.

    #38137

    In reply to: Table row index number

    Sam Moffatt
    Participant

    The 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.

    #38136
    Daniel Leu
    Participant

    Script 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&tricks

    #38135
    Martin Inchley
    Participant

    That’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.

Viewing 15 results - 2,191 through 2,205 (of 2,987 total)