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 - 1,006 through 1,020 (of 2,989 total)
  • Author
    Search Results
  • #46596

    In reply to: Inventory Script

    Sam Moffatt
    Participant

    Random thought: you could go crazy with a few more forms but it feels like at least “purchase point” should be it’s own form (you could do a form for brewery, styles and sizes as well then use links but that might be overkill?). Purchase point is definitely a candidate for it’s own form and I think sizes might help as well because it seems like you’d have standard sizes.

    I did a tutorial on managing balances with Tap Forms using yarn balls as an example and products like hats. There are two videos, the first video sets the ground work forms and has a simple script for setting the balance whilst the second video walks through building the scripting to add and remove entries maintaining the balance. These should help you handle reducing the inventory quantity when applying new parts but it does rely upon form scripts to work properly.

    In your case you still need to have something that figures out the quantity you want to reduce by for the purchase points to make it work properly. That might just be a simple prompter entry that then creates the entries for you automatically. I personally use prompters a lot for quick entry of information which speeds up data entry because I can hit the three fields I need rather than load up an entire form.

    #46594

    Topic: Inventory Script

    in forum Script Talk
    Neil Bontoft
    Participant

    I have what I think is a very simple question but I sadly haven’t got a clue how to answer it.

    I use Tap Forms v5 as a tool to record inventory in my cellar. Columns include:

    • Brewery
    • Beer
    • Size
    • Style
    • Purchase Point

    I would like to monitor the quantity of each bottle. It’s not as simple as using an integer and increasing or decreasing as fields like Purchase Point can vary depending on where the bottle was bought.

    I have created a concat field that combines Brewery, Beer and Size. This field effectively creates a string for the unique beer which I think could be used.

    I guess I have two options:

    • A field script that for each record (circa 900) could check if the concat field equals other concat fields and count as appropriate.
    • A new form which uses the concat field and does a count against each record for the concat field. To do this I would also need the script to copy the concat field, and remove any with zero quantity.

    Advice is massively appreciated. Cheers

    • This topic was modified 3 years, 11 months ago by Neil Bontoft.
    #46588
    Kirk Williams
    Participant

    Thank you so much Sam! I will definitely need to spend some time with this (given my limited scripting experience), but this is precisely the type of logistic advice I was hoping for.

    Your time and guidance are very much appreciated!

    #46584
    Rob Naaijkens
    Participant

    Maybe some more information on what I am trying to do.

    First Form: (Assortiment wijnen) all unique records with a Table field “Verkocht” in that table there are 3 records at the moment. The total of the record with “Aantal” I would like to show-up in the second form.

    I would like to use the table because these are wines and I would like to see the price per year of period.

    Second Form: This is where I would like the total of all the “Aantal” records from the first form.

    On your explanation I made the following script. First ID is the field “script” itself and the second is the ID of the field “Aantal” form the first form.

    The script works, no errors but the result on both numbers and text is nothing or <empty>.

    Hope this makes any sense ;)

    Attachments:
    You must be logged in to view attached files.
    #46583
    Rob Naaijkens
    Participant

    Hello Sam,

    Thanx for the quick reaction! Is it possible to tell me the complete code of the script? I’m a beginner ;)

    I like to try your solutions and will post the results later.

    #46581
    Sam Moffatt
    Participant

    Do you mind expanding a little on your structure?

    If you’ve got a link from the second form to the first, you can create a script field that traverses the link to form field (actually might be easier to do it as a link from form field) and then you can call linkedRecord.getTotalOfLinkedFieldForField(tableFieldId, fieldInTableId) to get a total of the field in the table (first ID is the ID of the table field itself, second one is the ID of the field you want to get the total of in the table). This actually becomes a one liner if you only have a 1:1 style mapping with the second form (link to form 1:M from the first to the second will give you a singular relationship in the second form). If there is a many relationship from the second form to the first, then you’ll need to get all of the linked records, loop over them, get the total and then sum it together.

    If you’ve going to programatically populate the second form, then that’s a loop to create the record and the same getTotalOfLinkedFieldForField on the source record to calculate the total of the field in the table field.

    Share a little about how the two forms are linked (or not) and how you interact with the two forms. The CRM video I did recently has a bunch of fun with linking forms together as well.

    #46580

    In reply to: Help with a script

    Sam Moffatt
    Participant

    If you post your scripts to date and maybe the form template folk on the forum can probably help. One of the cool things about the forum is that everyone can benefit from your questions and any solutions :)

    #46579
    Sam Moffatt
    Participant

    When you use Siri Shortcuts, you need to use the x-callback-url feature to load Tap Forms to trigger the document interaction. I did a video on using the x-callback-url to trigger a script from Siri Shortcuts. Otherwise I believe it invokes Tap Forms in the background (via a library I think?) and doesn’t permit any interaction with scripting. The Siri interactions API is kind of limited in what it allows so if you want any sort of interactive experience, I’ve only really seen it possible via the Shortcuts app.

    #46577
    Stig Widell
    Participant

    Hi,
    Is anyone willing to help a Swedish farmer with a record script in his cow data base?
    No knowledge in JavaScript!
    Brendan Duddrige has helped a lot with two earlier scripts but is too busy now for a third one.
    Will send document via e-mail.
    Regards
    Stig Widell

    #46574
    Rob Naaijkens
    Participant

    I have a series of records with a Table Field. I would need to use their total value in a second form. Is it possible with scripting? And if so, what is the way to do this?

    #46571
    Prashant M
    Participant

    Dear Daniel , I will definitely use back-ticks and link to the post

    Thanks for the script , It works properly on my OSX also when I try to use the same on iPhone manually it works (via Scripts->RUN)

    BUT if I add the script to Siri Shortcuts , I simply get a DONE message and no prompt to enter. Please see screenshot attached for the same.

    Dear Sam, Thanks for the link , I’ve installed the same on OSX , and I see 19 scripts :) I will be studying these and updating !

    Attachments:
    You must be logged in to view attached files.
    #46564
    Sam Moffatt
    Participant

    I also have some Prompter Functions in the Script Manager that might help you as well. Same note as Daniel that your calling function needs to be declared async to use these.

    #46561
    Prashant M
    Participant

    This is my first Script Trial , so apologise for my n00bs qs

    There are multiple prompter scripts floating on forum but I don’t know which one to pick up. I’ve tried to patch together adding a simple record in site_id but it fails

    var site_id = ‘fld-790b9d32090d4fd1873119a3e6401ec6’;
    function textPrompter(title, text=””) {
    return new Promise(function(resolve, reject) {
    let prompter = Prompter.new();
    prompter.cancelButtonTitle = ‘Cancel’;
    prompter.continueButtonTitle = ‘Continue’;
    prompter.addParameter(text,’prompterVar’)
    .show(title, ((status) => {
    if (status == false || prompterVar == undefined) {
    reject(‘Cancel’);
    } else {
    resolve(prompterVar);
    }
    }));
    });
    }

    var newRecord = form.addNewRecord();
    newRecord.setFieldValue(site_id, prompterVar);

    textPrompter();

    #46557
    Daniel Leu
    Participant

    It is not that complicated! This is a form script that loops through all records. It reads that value of your note field, modifies it, and then writes it back. Additionally, it checks that the note field content is defined, otherwise further processing is skipped.

    The script currently replaces all line-breaks with a whitespace and removes all leading and trailing whitespaces. As you see, you can use your regex in JavaScript as well :)

    The only change you need to make is define the note_id constant according to your form script. There are several ways to get the id. One way is to click on the field name in the script editor, then select and copy the ID string that is displayed underneath all the field names.

    function Remove_Spaces() {
    
       const note_id = 'fld-xxx' // set note_id according to your form
    
       for (let rec of form.getRecords()){
    	
          // get note field
          let note = rec.getFieldValue(note_id)
          console.log("Orignial note: " + note)
    
          // Check that note is defined
          if (note) {
             // modify note (replace line breaks with
             // whitespaces and remove whitespaces from
             // both ends of string
             let modifiedNote = note.replace(/\n/g, " ").trim()
    			
             console.log("Modified note: " + modifiedNote)
    	
             // save note field
             rec.setFieldValue(note_id, modifiedNote)
          }
       }
    	
       document.saveAllChanges()
    }
    
    Remove_Spaces()
    • This reply was modified 3 years, 11 months ago by Daniel Leu. Reason: replaced tabs with ' ' for better readability
    • This reply was modified 3 years, 11 months ago by Daniel Leu.
    • This reply was modified 3 years, 11 months ago by Daniel Leu.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #46551
    Brendan
    Keymaster

    You would probably need to write a Form Script that looped through the records then fetched the values for the fields you want to trim and then use the JavaScript trim() function.

Viewing 15 results - 1,006 through 1,020 (of 2,989 total)