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 - 1,516 through 1,530 (of 2,952 total)
  • Author
    Search Results
  • #43015
    Chris Ju
    Participant

    Here is an example (with german words), which works for me:

    function Record_Colour_Script() {
    	var erledigt_id = record.getFieldValue('fld-0f62df9131e64cdeae7b1a98580e700b');
    	var aufgehoben_id = record.getFieldValue('fld-f7738e96b4154742965b96ea5c697e31');
    	var gestrichen_id = record.getFieldValue('fld-a108b72455cb4fc8aa6354646e01fe1b');
    	var nicht_abrechenbar_id = record.getFieldValue('fld-5b27768928a3423ebddd542e3e05823f');
    	var abgerechnet_id = record.getFieldValue('fld-db41b041736543c697fc78671b0f2777');
    	
    	if ((aufgehoben_id == true) || (gestrichen_id == true))  {
    		colourHex = '#9D9D9D';	// rot
    	} else { 
    		if ((erledigt_id == true) && (abgerechnet_id == false) && (nicht_abrechenbar_id == false))  {
    			colourHex = '#ff9933'; // orange
    		} else {
    			if ((erledigt_id == true) && ((nicht_abrechenbar_id == true) || (abgerechnet_id == true))) {
    				colourHex = '#008000'; // grün
    			} else {
    			colourHex = '#ffff66'; // gelb
    			}
    		}
    	}
    	record.setRecordColor(colourHex);
    
    	form.saveAllChanges();
    	
    }
    
    Record_Colour_Script();
    #43014
    Philip Jones
    Participant

    Hello all,

    I am trying to follow Brendan’s instructions here: https://www.tapforms.com/forums/topic/programmatically-set-record-color/

    By using the following code:

    function Change_Record_Colour() {
    
    	var ffs = record.getFieldValue('fld-c629f095416d4df5be8e1a7de4fd81ba');
    	
    	if (ffs) {
    	    record.setRecordColor = '#ff0000';
    	    console.log("red");
    	}  else {
    	    record.setRecordColor = '#ffffff';
    	   	console.log("white");
    	}
    	
        form.saveAllChanges();
    
    }
    
    Change_Record_Colour();

    But it is not actually changing my record colour.

    The console is recording the correct values, so I know my *if* conditions are working OK.

    I am able to change the record colour using the colour picker at the bottom of the record, just to the left of the refresh arrow icon and the size of the record in KB.

    Am I doing something wrong?

    Thanks,

    Phil

    #42985
    john cesta
    Participant

    I had memento too. While you can export to cvs from memento the images get dumped as URLs. You will be able to import the memento csv file to TF but i don’t know about the images. And in memento if you saved descriptions/notes it exports as funky coded stuff.

    I never used memento to send to google sheets. I looked at the value of it but never needed to use it that way.

    you can export TF to csv and send it just about anywhere. I imagine with scripting etc you can run this function programmatically.

    But I would also go as far as to say you could probably recreate your entire application with TF and run it on Mac. ;)

    good luck

    Rich Trice
    Participant

    I am looking to move from an android devices and one of the biggest hold ups is the fact that I use memento database as a database. Today with memento I use a database to catalog “inventory” items daily and when I am done for the day I sync with Google Drive/Sheets from their I can import my data from the sheet and drive into my line of business application.

    What I need to know is if I can sync the tap forms database and images to a “cloud” server and then download a csv and images to a PC as my line of business application only runs on a PC. Today my csv/excel file when exported has the following columns

    Inv #, Title, description, value, category, image names, image urls

    Is this something tap forms can do?

    Thanks in advance

    #42976
    Sam Moffatt
    Participant

    Sometimes you want to look at the contents of the parent linked form whilst you are inside the child record. If you’re using custom layouts this makes it a little easier to pick up and embed targeted values. I also have used calculation fields to project in the parent title to forms so that I can see it in the record list.

    You can set a calculation field to calculate only once which should happen when the record is created. Whilst I’ve not directly tested this, in theory if you reference the parent form fields it should capture the value as that point in time and then lock it as uneditable. You would need to have created the record from the parent record and would only obviously only work for a single parent record.

    A pattern I use when working with script fields is to have them update actual fields and then check to see if those fields have a value already. It means you can reset their value manually if you really want to or you could delete the value to have the script reset it. That allows you to “fix” things or change them easily. I also have a pattern where I use the script field itself to store state as well by return a JSON encoded value for the script field and then reading the script field back to check the previous state.

    A common pattern for maintaining temporal records is effective dated records. If that sort of model is important to you then you could store a shadow copy of your form that is effective dated and then use a script field to replicate the current field values. It generally is more effort than it’s worth though and future dated records likely wouldn’t work properly.

    Hope this helps!

    #42971
    Brendan
    Keymaster

    You use a Calculation or Script field to copy the value from the parent record into the child record so that Tap Forms can provide the ability to search and sort the child records based on values in the parent record. That’s why Tap Forms copies the value using the Calculation field as a way to do that. You can tell the Calculation field to only evaluate one time. Then Tap Forms won’t put in a new value for it if the Calculation field already has a value. A Calculation field is just like a normal Text, Number, or Date field, except that its value is derived from the formula. The value is still stored just like the other field types.

    #42968
    Paul Wirth
    Participant

    I’m importing some records of clients via csv. One column in the csv contains multiple appointment dates per client.

    I want the clients to go into my Clients form. The Clients form has a Link to Form field called Appointments. It’s a 1:M field and “Show Inverse Relationship” is checked.

    I need the clients to be imported as records in the Clients form, and the multiple dates per client from the csv to be entered as child records in the Appointments form.

    I don’t think there’s a way to do that all in import, so I figured I’d:
    1. Import the csv into Clients, while creating a new field “Dates to Process” to capture the multiple appointment dates
    2. Use a script to loop through “Dates to Process” and create the appropriate records in Appointments

    For step 2, I’m pretty sure I can loop through the “Dates to Process”, but I don’t know how to apply each date as a new record in “Appointments” that’s associated with that client in the parent Clients form. I see that in the script editor, I can tap on one-to-many icon next to Appointments, and get its ID, but after that, I’m at a loss.

    Any help would be appreciated!

    #42964
    Philip Jones
    Participant

    Additionally you can use a “Calculation” field in the “Role Map” form to copy across details from the consultant table. This should get updated automatically when the consultant record is updated though there are a couple of times where I’ve confused TF enough for it not to propagate the changes (the exception not the rule).

    Sorry for resurrecting this thread, but I did have a question about the advice above (for my own understanding).

    Since the underlying data (the “truth”) is already stored in the related form, why would one copy the data into the calculation field? Is this not redundant as opposed to, say, referring to the original data field using a script?

    One possible advantage of doing that (at least that I could identify) would be to transactionally put the related data into a calculation field and then not update the field unless directed to do so by the user. This would have the effect of setting the data at “time zero”, allowing the underlying data (in the related field) to be updated without modifying the related record. In situations where one needs the correct historical record AND the ability for the related forms to have updated information as time goes by, this could be an advantage. However, in my limited knowledge, this is not the way Tap Forms works, correct?

    Thanks for any insights.

    #42961
    Sam Moffatt
    Participant

    When you’re working with a linked record, you need to get a copy of that record. If you double click on “Procedures” it should insert some code to help you get the procedure record. It should look something like this (if it inserts just an ID then you can update it to match):

    var procedures = record.getFieldValue('fld-1234');
    

    Where the fld-1234 piece will be the value that the script editor puts in when you double click on the “Procedures” section heading. I did a video on building a script that has some details that might be useful. There are a few other videos on the channel that could fill in some gaps. There is also T.L. Ford’s Tap Forms Scripting 101 and 102 as other resources that might help.

    That said since you’re on the “one” side of the 1:M field, if all you’re after is copying the value from the parent then using a calculation field is likely going to be simpler. Calculation fields in that situation will let you just double click the field you want and it should do the heavy lifting for you.

    One schema recommendation is to use a third form that stores two link fields for going back to patient and procedure. You link 1:M from Patients and Procedures into this new form, let’s call it “Appointments” (I’d use “Operations” but that could be confusing), make sure you tick “show inverse relationship”. This leaves the “Appointments” with a single link back to the other two forms which means you can keep stuff like patient name unique unless you don’t have a lot of recurring patients. If what you’ve got it working that’s great but I’d generally take a step further to split patient from the instances of a procedure they have so that their data (name mostly it seems) is only in one place.

    #42955
    Philip Jones
    Participant

    Hello all,

    I am trying to migrate an existing FM database to Tap Forms. Before I purchase I am trying to ensure I can make the basics of my existing db work.

    Please forgive my naïveté as I am a beginning user of Tap Forms.

    I have two tables: Patients and Procedures (surgical).

    A patient can have one surgery; many people can have a given surgery. Therefore, on the Procedures table (screenshot 1) I have ‘Patients’ set up as a one:many field. I have the ‘link to form’ turned on so that, in my Patients table (screenshot 2) I can see the linked information correctly.

    What I am attempting to do is to get the values of some of the related fields (from the Procedures table) into the Patients table. I am using a Script field for this. As per the attached screenshot, I am first trying to get the ‘OHIP code’ (‘C111A’ in the second screenshot) into its own field on the Patients table.

    I have attached a screenshot of my script where I attempt to do so. It is not working and I know the fix is likely something quite simple.

    In the Script window, the field ID was obtained by double-clicking on the “Code” field in the “Procedures” table on the left-hand side of the window.

    Any help to get me on my way would be much appreciated.

    Thank you.

    Phil

    Attachments:
    You must be logged in to view attached files.
    #42940
    Brendan
    Keymaster

    Hi Chris,

    That’s a cool use for Tap Forms!

    I took astronomy in university. It was one of my favourite courses.

    Although you’ve figured out another way to do what you want, your original question could be answered with a script to fetch an image from somewhere and populate the image in your form. If you had a folder on disk with photos in it, you could write a script to add a photo to your field from a URL using record.addPhotoFromUrlToField(url, field_id); You could set the photo field empty before adding a photo to it, otherwise you’d get multiple photos in the field.

    Anyway, just thought I’d chime in with this bit.

    Thanks!

    Brendan

    #42894
    Brendan
    Keymaster

    What about something that triggers a Form Script in Tap Forms that uses the new parameters feature that then causes the script to call back to an Amazon API to get the product details? I don’t know anything about building Chrome extensions though.

    But there’s information about calling a Tap Forms Script from a URL and passing it parameters here:

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

    #42893

    In reply to: Inventory number

    Brendan
    Keymaster

    Possibly one way that would be relatively quick, although as Sam said, would get slower over time too, but would be easy to implement, would be a script that simply looped through all the records and re-numbered them all from 0…N, for whatever numbering scheme you are using. You wouldn’t need to look for holes as this would effectively eliminate holes and your new records would just go to the end. But then as Sam suggested, reusing IDs or in this technique, changing IDs of an item isn’t always a good idea. But it really depends on what your workflow is.

    #42890

    In reply to: Inventory number

    Sam Moffatt
    Participant

    I think a script would be a lot of overhead for this just because as the number of records increases, you’d have to scan through them to find where the holes are and allocate a new ID. It’s possibly but it’d get slower over time.

    What I think might make more sense is a script you call to empty the record out and then a script field (that you can hide) that detects if some key fields are empty which you then key into a saved search for “available” records. Then you can repurpose those records as you need them.

    I personally don’t think I’d ever want to reuse ID’s in a collection and would probably always keep them as is with a flag that says I don’t have the item any more but that’s perhaps just me.

    #42889
    Sam Moffatt
    Participant

    You can do it but it relies upon using CouchDB sync (or Cloudant) to land the items. I use CouchDB as my sync and I have a bunch of Greasemonkey/Tampermonkey scripts that I use to push stuff into Tap Forms.

    Basically you can create a document in CouchDB with the same structure as a Tap Forms record. CouchDB let’s you do a POST to it to create a record via it’s web interface, Tap Forms then sees that record as a new record and it pops into it’s UI.

    I have two scripts that I use to automatically import this forum into a Tap Forms document as I navigate around it, essentially each time I go to a page on the forum, it scrapes the page into CouchDB and then shows up in Tap Forms. Here’s a copy of the topic collector piece that shows importing topics and authors as new records. It’s a bit of a hack as there are some protections on the tapforms.com side to prevent sending to external domains (hence the cspbypass.google-analytics.com hack).

    I started building one to import Amazon product pages but I never finished it. It’s a fair amount of work to basically use Javascript to extract out the pieces of the page you’re interested in and then splice it into a Tap Forms document. Not impossible just time consuming.

Viewing 15 results - 1,516 through 1,530 (of 2,952 total)