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 - 571 through 585 (of 2,989 total)
  • Author
    Search Results
  • #49375
    Victor Warner
    Participant

    Daniel,

    Thank you for the information.

    It has to be in JavaScript as is needed for use within a longer script.

    #49372
    Daniel Leu
    Participant

    The easiest I think would be to use a calculation field instead of a script field: DATEADD([date_of_notarial_act];0;0;0;5;0;0;0).

    Or in Javascript

    // Create date object
    let write_up_notarial_register_date = new Date(date_of_notarial_act);
    
    // Add five days to current date
    write_up_notarial_register_date.setDate(write_up_notarial_register_date.getDate() + 5);

    Cheers, Daniel

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

    #49371
    Victor Warner
    Participant

    In a document I have a date field which is referenced such has

    var date_of_notarial_act_id = 'fld-76fd68bf708e4bde87998a0cba32ffcd';
    var date_of_notarial_act = record.getFieldValue('fld-76fd68bf708e4bde87998a0cba32ffcd');

    but I would like to add 5 days to it and then that new date written to another form. Doing something such as:

    var write_up_notarial_register_date = date_of_notarial_act + 5;

    Does not work. Is what I would like to do possible with JavaScript in Tap Forms?

    Any help would be gratefully appreciated.

    #49369
    Pinny Berlin
    Participant

    Hi, I have a To-Do List form with hundreds of records. I am trying to duplicate the form with all of its records so that I can separate my Home tasks and Work tasks into two separate forms.

    I tried to Export a Tap Forms Archive, and then import it back in, but it just overwrites the original form. I want to load it back in as a second, additional form. Then I will delete the Work tasks from my Home form, and I will delete the Home tasks from my Work form.

    What’s the easiest way to do this?

    I am using Tapforms for iOS (and am pretty comfortable using javascript if need be).

    Thanks,
    Pinny

    #49367

    In reply to: Name Lookup

    Chris Jordan
    Participant

    Well, I am giving up on scripts. I keep going round and round with this. I get the script to work in the console window while editing and then I go to the form and the field doesn’t update. I refresh both tables and go back to the script edit window and now the console values don’t work. So frustrating. I think there is an update issue in the software.

    #49362

    In reply to: Name Lookup

    Chris Jordan
    Participant

    That’s a good tip! Thanks Brendan.

    My script still isn’t working the way I wanted it to because in the Donations table I still have to manually select the Parent data in the “People” inverse relationship field. If I don’t select anything my script doesn’t work. I wanted to be able to put the Envelope ID in the Donations record and have it automatically look up all the relevant data in the People table. I don’t know if I am making any sense or not.

    People Donations
    ====== =========
    Envelope Envelope (manually entered)
    First Name First Name (auto fill from the script)
    Last Name Last Name (auto fill from the script)

    Anyway, I think I am going to just have one form and put the Donations on each person’s data in the People table.

    Thanks,

    Chris

    #49357

    In reply to: Print or alert?

    Daniel Leu
    Participant

    You can use console.log() to output variables and text to the console:

    console.log(var);
    console.log("text");

    Depending on the object, you might want to use console.log(JSON.stringify(var)).

    To create an alert, use Utils.alertWithMessage('Script Run Complete!', 'Cool!!!!!');

    Hope this helps!

    Cheers, Daniel

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

    #49356

    Topic: Print or alert?

    in forum Script Talk
    robinsiebler
    Participant

    I am trying to debug a script. How can I print or show an alert?

    #49351

    In reply to: Name Lookup

    Brendan
    Keymaster

    hi Chris,

    The Child Records Loop snippet is designed to fetch the child records, not the parent record. So in your case, the People form is the parent and the Donations form is the child. So if you wanted to put a field on the People form that say, concatenated all of the donations for that People record together, that’s when you would use the Child Records Loop.

    Yes, Documents are like Databases. Logically and technically as each .tapforms document is actually a folder that contains within it its own SQLite database.

    And yes, Forms are like tables precisely. Records are of course like SQL records and fields are like Table Columns in SQL.

    If you want to automatically connect your forms together based upon some key field, then you would need to use the Join Link Type on your Link to Form field and set the common fields up. Then Tap Forms will auto-join for you.

    But that does in fact change the JavaScript code you would need to get the name values. Because with a Join Link Type, that is in fact the same as an automatic Many to Many relationship. That is, for each Donation record, there technically could be many People records and for each People record there could be many Donation records.

    So now when you get the value of the People field from the record, you’ll get an array instead of just the one object like in my code example. In this case, the Child Records Loop would work as expected.

    Hope that makes sense.

    Thanks,

    Brendan

    #49350

    In reply to: Name Lookup

    Chris Jordan
    Participant

    Hello again Brendan,

    I guess what I was originally trying to do, was write a script that:

    1. Automatically connected each donation to its parent record based on Envelope number.
    2. Automatically fill in the name field based on the Envelope number found in the parent record.

    Number two is what you just helped me with, however I had to manually select the parent record in the Inverse Relationship field, by looking up and connecting the correct Envelope number for the person. I know you have removed the SQL language, however now I have to understand the inner modeling of the application in order to write Javascript to pull the data.

    Still learning,

    Chris

    #49348

    In reply to: Name Lookup

    Brendan
    Keymaster

    By the way, to write that code, all I had to do was double-click on the People field on the left side of the Script Edit window. Then double click on the First Name field. Then all I typed was the return first_name and I wrapped it into a function structure.

    #49347

    In reply to: Name Lookup

    Brendan
    Keymaster

    Hi Chris,

    Ok, so your form is setup with People as the parent and Donations as the child.

    Your script is in your Donations form. Your script is attempting to loop through the parent People record. However, it’s not an array because it’s just one object. A Donation record has only a single People parent record. So you can just get the People record, then ask it for one of the fields.

    Since your script is called Firstname, I’m assuming you’re trying to get the People record’s First Name field.

    So all you need to do is first get the parent People record, then ask that record for the value from the First Name field.

    Here’s code to do that:

    function firstName() {
    	var people = record.getFieldValue('fld-042db77a64be4be0a8f041e927d5ff24');
    	var first_name = people.getFieldValue('fld-8c3880a29ec949e0a8ff1d502b527ae7');
    	return first_name;
    }
    
    firstName();

    That’ll do it. Hopefully that’s what you’re looking to do.

    #49338

    Topic: Name Lookup

    in forum Script Talk
    Chris Jordan
    Participant

    Hi,
    I have two Forms. One called Donations and the other called People. In the Donations form I have the script below where I’m attempting to look up the name of a person by Envelope number. I double-clicked the “Child records loop” Snippet with the People – Envelope field highlighted.

    For some reason I’m not getting any records (people.length = 0) even though there are 26 Records in the People Form. I am running the script in the Editor and length prints out 0. I must be doing something wrong. Can someone please give me some guidance.

    Thanks,
    Chris

    function Script() {
    
    	function recordsLoop() {
    	
    		var people_id = 'fld-16486faf17c94f779b495e39db0d2a51';
    		var envelope_id = 'fld-86ff175986c74617a1c71822bf7e9f2c';
    		var people = record.getFieldValue(people_id);
    	
    		console.log(people.length);
    		
    		for (var index = 0, count = people.length; index < count; index++){
    	     	var envelope = people[index].getFieldValue(envelope_id);
    	     	console.log(envelope);
    	     	
    	     	if (envelope) {
    				// do something
    				console.log(envelope);
    			}
    		}
    		return;
    	}
    	
    	recordsLoop();
    
    }
    
    Script();
    • This topic was modified 2 years, 9 months ago by Brendan. Reason: added back ticks around script code
    #49333
    Brendan
    Keymaster

    Hi Rudy,

    Make sure when you add your fields to your formula that you double-click on the field on the left side of the formula editor to insert the field into your formula. Don’t just type the field name. The square brackets around the field name are for the iOS version only.

    For your script, make sure you have the Result Type set to Number. The same for the calculation field.

    If you want me to look into your form, please email me your .tff file (export Tap Forms Form Template in the File menu).

    Thanks,

    Brendan

    #49330
    Rudy Zwartjens
    Participant

    Thank you Brendan for your – as usual – fast reply!
    The solution you describe is known for me (but still very useful as a reminder), so I now understand that I my explanation was not complete.
    I hoped to be able to “fill” a field – at least – with the number of different countries, so I could print that number together with the set list.
    BTW, the set list is printed using a label layout, the only way to get it printed like I want.

    In the meantime I was puzzling with a DIY solution.
    I used a checkbox field [c.change] with a check on every first tune in a country:

    Garoon Armenia check
    Hey Par Armenia
    Hora Romenia check
    Musette1 France check
    Musette2 France

    With your described method I found: 3 countries, right!
    To get this count value in a field I used a calculation field with formula:
    IFNOTEMPTY([c.change];sum([c.change]);0) . In the formula I used no brackets.
    The result was empty, so this appears not to be right (too simple?).

    Then I used a script field using a sample for summation:

    function getFieldTotal() {
    var field_id = record.getFieldValue(‘fld-5e8d5d2744d4e2cbdbc9f3d7ac1cc35’);
    // whatever the field ID is for the field you want the total of.
    var total = form.getTotalOfField(field_id);

    return total;
    }

    getFieldTotal();

    Also this field stays empty. So it is clear: I still have to learn a lot!

    Will you please give me a hint in the right direction?
    I am not afraid of programming, but I have no experience with Java.

    Thanks in advance.

    Rudy

Viewing 15 results - 571 through 585 (of 2,989 total)