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,401 through 2,415 (of 2,864 total)
  • Author
    Search Results
  • #35089
    Sam Moffatt
    Participant

    This will work, it requires using script field instead of calc field but it’s not that bad. You need to tell it the value you want to lookup with, the “join” field (table or link to form), the search field to match the lookup value on and then the field to return.

    Create a new form script called “vlookup” with the following contents:

    function vlookup(lookup, join_field, search_field, return_field) {
    	var entries = record.getFieldValue(join_field);
    
    	for (var index = 0, count = entries.length; index < count; index++){
         	var target = entries[index].getFieldValue(search_field);
    		if (target && target == lookup) {
    			return entries[index].getFieldValue(return_field);
    		}
    	}
    	return "";
    }

    Then create a script field to map the values across:

    form.runScriptNamed('vlookup');
    var addresses_id = 'fld-34e22de8a7cf438fb4a83146108f0511';
    var address_name_id = 'fld-f05929829d674141aaed98efe11e29f1';
    var street_id = 'fld-04ec2a23e3554770b3e1f1d771157dd6';
    var primary_address = record.getFieldValue('fld-9b2865aa57b74b70bd4421b27081d65b');
    
    vlookup(primary_address, addresses_id, address_name_id, street_id);
    

    In the script editor, select the fields from the linked form and use the “ID” button instead of double clicking them to get the var syntax. You’ll want to change the last field to match your fields across.

    I’ve attached a sample archive which should demonstrate what I’m talking about. It also has another form script using a prompter to handle the address change but for some reason the script fields aren’t updating afterwards, you have to manually press refresh on the record.

    Attachments:
    You must be logged in to view attached files.
    #35057

    In reply to: Key Word Automation

    Brendan
    Keymaster

    So you want all the spaces to be replaced with underscores within the value of a field? Is that what you’re wanting?

    If so, you can use a Script field with the following script:

    function Hash_Tag() {
    
    	var keyword = record.getFieldValue('fld-6ec7c1fdcc094a1c8d935b36158cb0a8');
    	var hashTag = "#" + keyword.split(' ').join('_');
    
    	return hashTag;
    }
    
    Hash_Tag();

    Replace the fld-... bit with the field ID from your own Keyword field.

    Attachments:
    You must be logged in to view attached files.
    #35035

    In reply to: Learning Javascript

    Brendan
    Keymaster

    Hi FourD,

    You can find out about what JavaScript is used in Tap Forms from this link:

    https://tc39.es/ecma262/

    But it’s more of a description of the language and not a tutorial.

    The Scripting topic in the manual and the API documentation should give you an idea how to go about things specifically in Tap Forms:

    https://www.tapforms.com/help-mac/5.3/en/topic/scripts

    You can basically use any JavaScript tutorials that are not specifically geared to programming a web browser. Or at least if you do, you can ignore the parts that refer to the DOM (document object model). Tap Forms uses JavaScript, but basically just for it’s syntax and functionality in the general sense. There is an API I added to it which gives you specific functions you can call that specifically work on your Tap Forms data.

    Here’s the API:

    https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api

    Thanks!

    Brendan

    #35034
    Sam Moffatt
    Participant

    The 0.02 number is your inflation rate, 2% in this case. Just change that constant to what ever you want it to be and refresh your record to get the updated value. If you tick the box for running only once it’ll stick. You could put an extra field in the form for the inflation rate you want to use for the record.

    With scripting you could do something a little more complicated and with some join fields you might be able to do something where you have a form with records per year and the interest rate you want to set.

    #35029
    FourD
    Participant

    Does anyone have any suggestions for references on learning the version of Javascript that is supported by TF?

    #35026
    joe omalley
    Participant

    Thanks Brendan, a step by step with the proper syntax and explanation in order to grab a value from a field in one form and insert it into another form. I’m just trying to get a visual utilizing Tap Forms scripting technique.
    I can’t grasp the written instruction of how to use java script in Tap Forms without seeing it in use inside the Mac version the program.

    #35009

    In reply to: Images in Search

    Brendan
    Keymaster

    You could just add a Script field, then click the Script Editor button to edit the script. Then copy and paste the code in my above example and replace the “fld-….” value with your own photo field ID. It’s right there on the Script Editor screen. Then save it. You’ll now have a field that tells you the number of photos in your Photo field. Now you can build a search on that.

    You don’t really need to know how to write scripting code. Just a copy and paste.

    #35007

    In reply to: Images in Search

    CollectorM
    Participant

    Oh, unfortunately I don’t know anything about using a script or writing one.
    But thanks for taking the time to answer me, I appreciate that.

    #35006
    Barry Shevlin
    Participant

    Might I please add my support to this request for a scripting video(s)? That would be very useful.

    #35004

    In reply to: Images in Search

    Brendan
    Keymaster

    Hi CollectorM,

    Yes there is. You can do that by using a Script field that returns the number of photos in your Photo field and then search the form for where that field value is 0.

    Something like this will work if you add a Script field to your form:

    var case_cover = record.getFieldValue('fld-e2cf02f376864a7cb9f090e4a597f3e4');
    
    if (case_cover) {
        case_cover.length;
    }
    

    Use the “fld-” value from your own form’s Photo field. You can get that from the Script Editor.

    Hope that helps!

    Brendan

    #35001
    Brendan
    Keymaster

    Hi Joe,

    Thanks for the request for a Scripting video. That would be great to have. I’ll see if the guy I hire to do that can make another one.

    Is there any specific thing you would like to see scripted?

    Thanks,

    Brendan

    #34996
    joe omalley
    Participant

    Brendan thank you for your continuous efforts in answering questions on this forum. Been using tap forms for about a year. Mac, IPad, IPhone with syncing. Works well and recommend the app often to IPhone users that I work with. Up to now using TF for keeping track of simple stuff such as hours worked, fuel purchases, work related miles driven. I would like to expand my knowledge and skill to utilize scripting to garner more power from the app. I am politely and respectfully requesting some training videos on how to perform some common tasks specific to the use of this fine software. I have found that with ever changing technology, I seem to grasp concepts and learn more effectively by watching “how to” vids. Looking for just a roadmap utilizing this software. I’ll hang up now and listen for your answer:)

    #34992
    Sam Moffatt
    Participant

    I use this script in a script field to materialise the child values into the parent field to make it searchable:

    function recordsLoop() {
       var retval = [];
    	var shipments = record.getFieldValue('fld-db2fcdb4d79c466ea09671c47d2ae645');
    	for (var index = 0, count = shipments.length; index < count; index++){
         	var tracking_number = shipments[index].getFieldValue('fld-7a29242731d9451092c92d8586dbc94a');
    
    		if (tracking_number) {
    			retval.push(tracking_number);
    		}
    	}
    	return retval.join(' ');
    }
    
    recordsLoop();
    

    fld-db2fcdb4d79c466ea09671c47d2ae645 is a Link to Form field pointing to the child records (shipping entries in this case) and fld-7a29242731d9451092c92d8586dbc94a is the tracking number in that shipping record.

    When you’re in the Script Editor for the script field, use the “records loop” snippet on the “Link to Form” field to get most of this boilerplate handled for you.

    #34985
    Sam Moffatt
    Participant

    You could possibly do a Link to Form with a JOIN type to get matches that way and then you could iterate over the values of the Link to Form field. Not quite a 1:1 match to the functionality but you could tie this together with a script field to get the exact value you want out of the children.

    #34978
    Brendan
    Keymaster

    Hi FourD,

    Sorry for my delay in replying. I just saw your post today.

    You can certainly do this with a Script field. You can ask for the array of records from a Link to Form field and then get the values from the field you’re interested in, then concatenate them together.

Viewing 15 results - 2,401 through 2,415 (of 2,864 total)