How do I make a Check Mark Script Reset

Viewing 5 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 14 hours, 42 minutes ago by David White.
Viewing 5 reply threads

You must be logged in to reply to this topic.