The Tap Forms JavaScript Application Programming Interface (API) provides you with specific extensions to the JavaScript virtual machine that lets you create, update, and delete various objects within your Tap Forms database document.

Here are a list of objects and the functions you can call on each.

Function Parameters Returns Description Example
document
saveAllChanges none Bool Call this to save any changes your script has made to the database document. document.saveAllChanges();
getForms none array of forms Call this to fetch an array of all the forms in your database document. document.getForms();
getFormNamed form name form Call this to fetch a form with the specified name. document.getFormNamed('My Movie Library');
form
addNewRecord none record Adds a new record to the form. var newRecord = form.addNewRecord();
getRecords none array Returns an array of record objects for the specified form. var records = form.getRecords();
deleteRecord record error string Deletes the specified record from the form. form.deleteRecord(someRecord);
saveAllChanges none Bool Call this to save any changes your script has made to the database document. document.saveAllChanges();
getFieldIds none array Returns an array of all the field IDs in the form. form.getFieldIds();
getTotalOfField field ID number Returns the total sum of all the records in the form for the specified field. form.getTotalOfField(fieldID);
getMinOfField field ID number Returns the minimum value of all the records in the form for the specified field. form.getMinOfField(fieldID);
getMaxOfField field ID number Returns the maximum value of all the records in the form for the specified field. form.getMaxOfField(fieldID);
getAvgOfField field ID number Returns the average value of all the records in the form for the specified field. form.getAvgOfField(fieldID);
getSearchNamed text Search Returns a search object given the name of a search. form.getSearchNamed('Genre: Action & Adventure')
selectRecord record none Selects the specified record on the form. form.selectRecord(someRecord)
search
getRecords none array Returns an array of record objects for the specified search. var records = search.getRecords();
getTotalOfField field ID number Returns the total sum of all the records in the search for the specified field. search.getTotalOfField(fieldID);
getMinOfField field ID number Returns the minimum value of all the records in the search for the specified field. search.getMinOfField(fieldID);
getMaxOfField field ID number Returns the maximum value of all the records in the search for the specified field. search.getMaxOfField(fieldID);
getAvgOfField field ID number Returns the average value of all the records in the search for the specified field. search.getAvgOfField(fieldID);
record
addNewRecordToField field_id record Used for adding a new record to a Link to Form or Table field. var newRecord = record.addNewRecordToField(field_id);
addRecordToField record, field_id none Used for adding an existing record to a Link to Form or Table field. record.addRecordToField(someRecord, field_id);
addPhotoFromUrlToField url, field_id none Fetches a photo from the specified URL and adds it to the Photo field specified by field_id record.addPhotoFromUrlToField(image_url, case_cover_id)
getFieldValue field_id object Gets the value for the specified field from the record. The return type depends on the field you’re getting the value from. var barcode = record.getFieldValue(barcode_id);
setFieldValue field_id, value none Sets the value on the specified field. record.setFieldValue(movie_title_id, 'The Terminator');
setFieldValues dictionary none Sets the values on multiple fields at once given a dictionary of field ids and values. record.setFieldValues({ [field1_id]: "value1", [field2_id]: "value2", [field3_id]: "value3" });
getNoteFieldValue field_id note value Gets the rich text note field value from the specified Note field. record.getNoteFieldValue(field_id');
setNoteFieldValue field_id, value none Sets the rich text note field value on the specified Note field. record.setNoteFieldValue(field_id, note_value');
getUrl none url Gets the URL for the record. This is the same URL as the Copy Record Link function under the Edit menu. record.getUrl();
Utils
getJsonFromUrl url JSON For the specified URL, returns a JSON response that you can get values from. var product_info = Utils.getJsonFromUrl(url);
getTextFromUrl url text For the specified URL, returns a text response. var product_info = Utils.getTextFromUrl(url);
getDataFromUrl url binary data For the specified URL, returns a binary data response. var photo_data = Utils.getDataFromUrl(url);
postJsonToUrl JSON, url dictionary For the specified URL, posts the JSON content. Utils.postJsonToUrl(json_string, url);
postContentToUrlWithContentType text, url, content type dictionary For the specified URL, posts the text content using the specified content type. Utils.postContentToUrlWithContentType(some_string, url, 'application/json');
alertWithMessage title, message none Displays an alert with the specified title and message Utils.alertWithMessage('Script Run Complete!', 'Cool!!!!!');

Prompter() function – for prompting for input.

You can also prompt a user for input parameters, then take the input and use it for populating fields. This currently only works on the Mac version. Here’s an example:

var output = function printOut(continued) {
       if (continued == true) {
	   console.log(username + ", " + password + ", " + email_address + ", " + other_field + ", " + genre);
       } else {
          console.log("Cancel button pressed.");
       }
}


var username;
var password;
var email_address;
var other_field;
var genre;
var genres = ['Action & Adventure', 'Comedy', 'Drama', 'Horror', 'Science Fiction'];

let prompter = Prompter.new();
prompter.cancelButtonTitle = 'No Thanks';
prompter.continueButtonTitle = 'Go For It!';
prompter.addParameter('Username: ', 'username')
.addParameter('Password: ', 'password', 'secure')
.addParameter('Email Address: ', 'email_address')
.addParameter('Other: ', 'other_field')
.addParameter('Genre: ', 'genre', 'popup', genres)
.show('Enter a Username and Password and Stuff', output);

Need more help with this?
Don’t hesitate to contact us here.

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.