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 - 661 through 675 (of 2,951 total)
  • Author
    Search Results
  • #48604

    In reply to: Number Formatting

    Matthew Carpenter
    Participant

    I’m learning!

    Okay so I took the old code and tweaked it to fit another line of data. The format does not need to change because it is simply a Student ID Number. I got it to spit out the same number but as a script. The scripted output is now my form and cannot be edited from the custom form.

    This is what I did;

    function formatStuID(val){
    
    	val = val.replace(/(\d)-(\d{4}).*/, '$1-$2');
    	return val;
    }  		
    
    function Formatted_Sin() {
    
    	var sin = 
    record.getFieldValue('fld-66039384e7ac46f0aecb546f5e8c4ac9');
    	console.log(sin);
    	
    	if (sin != undefined) {
    		return formatStuID(String(sin));//"1234567890"
    	} else {
    		return nil;
    	}
    }
    
    Formatted_Sin();

    BAM!!! Protected form value!

    #48592
    Brendan
    Keymaster

    Hi Matthew,

    There’s no function to lock a field on a custom form. You can lock the position of a field so you don’t accidentally move it. But that’s not used for preventing editing on a custom layout. But what you can do is just not include that field on your custom layout and it will still be available on the Default Layout. With custom layouts you don’t have to have every field available displayed there. Not even for script or calculation fields to work. They can be on your custom layout even without any of the fields they reference. And you can create as many custom layouts as you like.

    Thanks,

    Brendan

    #48589
    Matthew Carpenter
    Participant

    So I am new (as you may know).
    I went onto a coding adventure to output a value in a desired format.

    When I add a new record there are some values that are required for each record.
    Optimally I do not want those to ever be accidentally changed. So far being new to TapForms I have had to be very carful when using a copy/paste from MY form so I don’t change a value. When I enter a new record I use the default layout but when I dig in and use my data I use MY custom form.

    I do not know if there is a way to lock a value on a custom form but what I learned is that the output value of a script on MY custom form cannot be altered easily.

    So my silly question is, can we lock a value so it cannot be changed on a custom form but only from the default layout?

    #48578

    In reply to: Number Formatting

    Brendan
    Keymaster

    Oh, and the Script must be set to return a Text result.

    #48577

    In reply to: Number Formatting

    Brendan
    Keymaster

    You could actually parse the SIN numbers from one field, then format them using the script to display in another field.

    Here’s code to do that. Make a new field and set the Field Type to Script. Paste in this code:

    function formatSocialSecurity(val){
    	val = val.replace(/\D/g, '');
    	val = val.replace(/^(\d{3})/, '$1-');
    	val = val.replace(/-(\d{2})/, '-$1-');
    	val = val.replace(/(\d)-(\d{4}).*/, '$1-$2');
    	return val;
    }  		
    
    function Formatted_Sin() {
    
    	var sin = record.getFieldValue('fld-4289784906dd4822ab1b738c404ca783');
    	console.log(sin);
    	
    	if (sin != undefined) {
    		return formatSocialSecurity(String(sin));//"135-71-1458"
    	} else {
    		return nil;
    	}
    }
    
    Formatted_Sin();

    I didn’t make up the formatSocialSecurity() function. I Googled for it.

    You would have to replace your Social Security Number field ID with the one from your own form.

    The script requires the values to be Text, so this part converts it to a String: String(sin)

    See if that works for you. You may need to modify the code a bit to get the right format for you.

    #48576
    Brendan
    Keymaster

    Hi James,

    There’s no function in Tap Forms to write to the file system from a script. But adding write ability is something I’d like to do at some point.

    Although you can post to a web service, so maybe if you had some web service running on your Mac you could have that service write to the file system after receiving data from Tap Forms.

    Thanks,

    Brendan

    James Merryman
    Participant

    Hi! Is it possible to have tap forms create a new folder in finder named using data from tap forms fields?

    I would love to click a button in Tap Forms that would then create a new folder with a LastName_FirstName, then another folder inside with OrderNumber, Equipment Folder 1, Equipment Folder 2.

    Thanks for helping me find out if this is possible via Apple Script or another method :)

    James

    #48541
    Brendan
    Keymaster

    Scripts don’t run when you’re just browsing records. Imagine you had a script that took a long time to execute and you ran it for every record that’s displayed. It would make browsing miserable.

    So there’s no automatic way of triggering a script when clicking on a Saved Search. You would have to refresh the records list which would run every script on every record displayed.

    #48535
    Daniel Leu
    Participant

    Idea: how about assigning a keyboard shortcut to a script?

    Cheers, Daniel

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

    #48533
    Tim H
    Participant

    Thinking about this a bit more…

    Is there a way to auto-run a script based on a saved search? For example lets say I have saved a search that utilizes a rule that a particular field be non-empty. Additionally I have a saved search with a rule that specifies a field to be empty. Depending on which saved search I’m browsing records with, the script would “fire” either collapsing or expanding the section heading.

    Basically, I’ve got a long default form with a section containing a bunch of fields that I’d prefer not to see (collapse section) unless there is information in one of the fields within the section.

    Thoughts/ideas?

    T.

    #48527
    Tim H
    Participant

    Hi Brendan,

    I was able to use your bit of code and get the Section to collapse based on whether or not another field was undefined. It works great thank you!

    Now is there a way to get this script to “auto-run”? I’ve saved the script as a “form script” i.e. it’s not a script type field in the form but I have to manually run it each time. Ideally I’d like the script to run each time a different record is displayed i.e. collapsing/un-collapsing the section while browsing records.

    Thanks again for your help.

    T.

    #48526
    Brendan
    Keymaster

    The example above just toggles the section opened and closed each time you run the script. You will probably have different logic.

    #48521
    Tim H
    Participant

    I a real beginner with scripts in Tap Forms so am finding it difficult to collapse a section based on the contents of a field. Basically I’d like to collapse a section if another field is empty.

    I see from Tap Form’s JavaScript API there is something that looks like it should close a Section Heading type field (field.isCollapsed = true;) but when editing a form script the Section Heading type field I want to control does not appear in the list of Available Fields. I was able to get the field ID from the Fields List but still cannot programmatically collapse the section.

    I’d appreciate any tips on getting this to work. Thanks

    T.

    #48495

    In reply to: Conditional Fields?

    Daniel Leu
    Participant

    If you use a script, you can set the color of a record: record.setRecordColor('#cc9900');. Maybe that’s sufficient for what you want to achieve.

    Cheers, Daniel

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

    #48486
    richard maliszewski
    Participant

    I guess one way to do this would be to have the URL invoke a form script instead, with recordId as a parameter. Script could then look up the record, find the type, select appropriate layout and then select the record. Seems like that would get me where I want to be.

    –Richard

Viewing 15 results - 661 through 675 (of 2,951 total)