How do I make a Check Mark Script Reset

Viewing 9 reply threads
  • Author
    Posts
  • October 9, 2025 at 7:00 PM #53064

    David White
    Participant

    I play a mobile game called Clash of Clash on my iPhone 13. I use Tap Forms Pro on my iPhone also. I made a document named: My Games, and a form inside that named: CWL WARs, and inside that I made records that use 7 Check Mark Fields… Names: Fought Day 1, Fought Day 2, Fought Day 3, Fought Day 4, Fought Day 5, Fought Day 6, Fought Day 7. My Question is this: How can I make a Script on my iPhone 13 that will reset or clear all those Check Mark fields back to no checked boxes again. I am new at making scripts … so can you put it in Layman Terms as much as possible. I did read the beginner stuff tap forms puts out. So I got the very basic. My reason for wanting to do this is as follows. I can have 40 players I’m tracking during CWL WARs at any given time. Each record has 7 Check Mark boxes that can be clicked on. That’s 40 X 7 = 280 Check Mark Boxes I have to clear at the end of CWL WARs. It would be so much easier if I could just click a script and they were all reset / cleared at once.

    Hope to hear back from someone that can help me. First time using this Forum. Thanks. God Bless.

    October 11, 2025 at 1:15 PM #53065

    Shane
    Participant

    That’s a difficult thing to easily explain in layperson’s terms because it requires explaining a programming language. I”m new to scripting in TapForms, but have some experience with Javascript via web programming.

    You need to create a script field which gets run when the form is viewed (I believe). In the script, it would have to do the following:

    function uncheckRecords() {
    
    // get the ID of the form you want to get the records from
    var myForm = document.getFormNamed('CWL WARS');
    
    // get the ID of the checkbox field
    var checkMarkField = 'fld-11d1cd0f0dc64bc389c3298076f0b9c8';
    
    // get the records from that form
    var records = myForm.getRecords();
    
    // iterate through all records and set the charkMarkField to unchecked
    for (var index = 0, count = records.length; index < count; index++){
         // pull single record from array:
         var theRecord = records[index];
         // change field value for that record
         theRecord.setFieldValue(checkMarkField, 0, false);
         document.saveAllChanges();
    }
    
    }
    
    uncheckRecords();

    So this is how I see the code going in theory, but I haven’t tested it. I’m assuming that a check mark field would result in 0 (unchecked) and 1 (checked) just like a form would in Javascript but haven’t verified it in Tapforms. There are some other changes I’d make to this code to make it more efficient (such as an if then conditional to only change the records that are already checked) but for simplicity purposes I kept it this way.

    Good luck.

    October 12, 2025 at 3:04 PM #53068

    Brendan
    Keymaster

    Looks good to me Shane. Just make it as a Form script and run it whenever you want to uncheck all the records in the form. It won’t run automatically when the form is viewed.

    October 13, 2025 at 9:57 AM #53069

    David White
    Participant

    Hello Shane and Brendan.

    First I want to thank you both for your help.

    I got scared I was going to mess up my CWL WARs Form … so I made a practice form that does kinda the same thing.

    My practice Form is called: Reset Check. And I made only two checkboxes name: Day 1 and Day 2.

    I put your Script in and where it says:
    Var myForm = document.getFormNamed( ‘Reset Check’);

    As you can see I put: Reset Check.

    I put in the IDs For: Day 1 and Day 2.

    Everything seems to work … except I get this message that pops up:

    ERROR
    TypeError: myForm.getRecords is not a function. ( In ‘myForm.getRecords(); ‘myForm.getRecords’ is undefined), line:(null)

    I have no idea what that means. I was hoping it would work. I don’t know what to do to fix that.

    Hoping you might have a trick up your sleeve that can make this script work.

    Note: As I mentioned in the beginning… I only use IOS iPhone and iPad. I don’t have a Max Lap Top. Hoping it doesn’t matter. I am using Tap Forms Pro app i purchased. Thats why i chose this Forum. If i’m not suppose to be here… let me know. I will post my questions where i’m told to go.

    Thanks.
    God Bless.

    October 14, 2025 at 9:33 AM #53070

    Brendan
    Keymaster

    try myForm.fetchRecords(). In Tap Forms Pro I had to rename the getRecords() function to fetchRecords().

    Sorry, I missed seeing that in the script above.

    October 14, 2025 at 12:57 PM #53071

    David White
    Participant

    Oh… so close. I made the change: myForm.getRecords()… to: myForm.fetchRecords().

    It stopped the Error Message, and when i clicked on the script it even unchecked one of my two check boxes. It unchecked: Day 2. But not: Day 1.

    I will copy and paste here my script. Hope it helps make sense of it. In the script… First Field ID is Day 1. Second Field ID is Day 2. ( Only Day 2 checkbox resets ). My script below.

    function uncheckRecords() {

    // get the ID of the form you want to get the records from
    var myForm = document.getFormNamed(‘Reset Check’);

    // get the ID of the checkbox field
    var checkMarkField = ‘fld-f9318c6c66944131b69e29e75ab996db’;
    var checkMarkField = ‘fld-3adc2a737f9f468b8bb6be8327c9139d’;

    // get the records from that form
    var records = myForm.fetchRecords();

    // iterate through all records and set the charkMarkField to unchecked
    for (var index = 0, count = records.length; index < count; index++){
         // pull single record from array:
         var theRecord = records[index];
         // change field value for that record
         theRecord.setFieldValue(checkMarkField, 0, false);
         document.saveAllChanges();
    }

    }

    uncheckRecords();

    • This reply was modified 1 month, 2 weeks ago by David White.
    October 17, 2025 at 6:32 PM #53074

    Brendan
    Keymaster

    Put your document.saveAllChanges(); statement outside the loop. It would be causing a refresh of the records in the middle of the loop.

    October 17, 2025 at 10:31 PM #53077

    David White
    Participant

    I’m not totally clear what a loop is. But I think I got it out of the loop. I’ll paste what I did here. If I did it right… the script still is not working. It’s doing the same thing… It’s only blanking out Day 2 checkmark, and not Day 1 checkmark.

    Here’s what I did.

    function uncheckRecords() {

    // get the ID of the form you want to get the records from
    var myForm = document.getFormNamed(‘Reset Check’);

    // get the ID of the checkbox field
    var checkMarkField = ‘fld-f9318c6c66944131b69e29e75ab996db’;
    var checkMarkField = ‘fld-3adc2a737f9f468b8bb6be8327c9139d’;

    // get the records from that form
    var records = myForm.fetchRecords();

    // iterate through all records and set the charkMarkField to unchecked
    for (var index = 0, count = records.length; index < count; index++){
         // pull single record from array:
         var theRecord = records[index];
         // change field value for that record
         theRecord.setFieldValue(checkMarkField, 0, false);
    }
    document.saveAllChanges();
    }
    uncheckRecords();

    October 18, 2025 at 11:17 AM #53080

    David White
    Participant

    Hey Guy’s I got this thing working now. I researched through Google AI. It took a ton of trial and error… but i finally got it. Remember in the javascript… Reset Check was my form i made. Day 1 and Day 2 was my checkboxes. Blank was the name of my Script.

    I just wanted to click on my script ( named Blank ) one time, and Day 1 and Day 2 checkboxes ( In ALL my records at once ) would reset. The following pasted javascript does that for me now.

    // Function to clear all checkbox fields in every record
    function BlankAllRecords() {
    // Get all records from the current form
    var allRecords = form.fetchRecords();

    // Field IDs for your checkboxes. These are unique to your form.
    var day1FieldId = ‘fld-f9318c6c66944131b69e29e75ab996db’;
    var day2FieldId = ‘fld-3adc2a737f9f468b8bb6be8327c9139d’;

    // Loop through each record in the form
    for (var i = 0; i < allRecords.length; i++) {
    var aRecord = allRecords;

    // Set the value of the checkbox fields to 0 (unchecked) for the current record
    aRecord.setFieldValue(day1FieldId, 0);
    aRecord.setFieldValue(day2FieldId, 0);
    }

    // Save all changes after looping through all records
    document.saveAllChanges();

    // Optional: Add a message to the console for debugging
    console.log(“All records have been reset.”);
    }

    // Run the function
    BlankAllRecords();

    Hope this helps others in some small way.
    Thanks Shane and Brendan.
    God Bless guys.

    October 20, 2025 at 9:55 AM #53082

    Brendan
    Keymaster

    Glad you figured it out. Just re-reading your script a little more closely you did define the same checkmark variable name with two different IDs and your final version shows different variable names, which is correct.

    Sorry I didn’t examine it more closely before.

    A loop is the for (....) { } structure in your code. You don’t want the call to save within that because it’ll cause a refresh every iteration through the loop.

    I’m glad you figured it out.

    Sometimes programming is just trial and error. But through each iteration, you learn more and know what to look for the next time so you don’t make the same mistakes again.

Viewing 9 reply threads

You must be logged in to reply to this topic.