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,446 through 2,460 (of 2,864 total)
  • Author
    Search Results
  • Victor Warner
    Participant

    One form in the Script editor is now indicating that when I click on the ‘Run Script’ button that
    it cannot find the variable ‘result’ = “ReferenceError: Can’t find variable: result, column:7, line:17”

    For a new field which contains the script no value is shown in the field (ie it is blank)

    With the same script in another field which was entered previously entered, that field still shows the data (although in Script editor, when clicking on the ‘Run Script’ button, I also get the same error).

    This error is affecting all of the fields containing a script, but not other forms.

    One of the scripts is:

    var directors_id = 'fld-b97b1fadf82f42e08b2f8be84b5a0bb9';
    
    director_name_record = record.getFieldValue(directors_id)
    
    if (director_name_record.length >0) {
    
    var first_director_name_record = director_name_record[0]
    
    var client_name_individual_upper_case_id = 'fld-7601d096dbd445aaa498645e199ecd29';
    
    var UpperCaseName = first_director_name_record.getFieldValue(client_name_individual_upper_case_id)
    
    result = UpperCaseName
    
    }
    
    result;

    Why might this be the case?

    #34262
    Victor Warner
    Participant

    Brendan,

    Thank you for the response, but my query was directed to adding further code to the code I posted: a further if statement.

    Using the field names in my first post:
    1. The Script Field contains the code I posted and to which I add an if statement

    2. Directors Signing Field either nothing or a number (but being a text field)

    That is (using the field titles in my first post):

    If Directors Signing Field is empty then result (ie the result in the code posted)

    otherwise make Script Field blank

    #34238
    Brendan
    Keymaster

    I think the code ou have is correct.

    To check to see if there are any entries in your new_identified_work_record array, checking its length > 0 is appropriate.

    Do you get any errors when you click the Run button in the Script editor?

    Victor Warner
    Participant

    Brendan,

    I would be grateful for some help in adding the right JavaScript to existing code you provided.

    I have a several Forms in the same database. The two which are relevant:

    A. a Form to record details of documents (Document Form)
    B. a Form which lists the names of persons who will sign an individual document (Director Form)

    In the Document Form I have created a Link to Form from Document Form to Director Form (One to Many.)

    Some documents in the Document Form will be signed and some will not. If the document is signed then I will use Linked to Form field to choose a director from the Director Form.

    In the Document Form I have then created:

    (a). a further field which with a script (which you provided and I adapted) to extract certain detail from the Director Form (Script Field). See below for the code.

    (b). a further field (text) which states the number of directors signing (and is populated by a pick list (eg 1, 2, 3 etc)) (Directors Signing Field)

    For example:

    1. for one record in Document Form I may have a power of attorney which needs signing and I will add in the Linked to Form field a director (using the tick option, Select existing linked records)
    2. for another record in Dcoument Form I may have an official document which does not need signing, and I will not add a director.

    The issue is that in the Script Field is as follows:

    i. that if the document needs signing, and I will select the director and the Script Field will be populated as expected.

    but

    ii. that if I create a record in the Document Form where a document does not need signing, I will not add a director in the Linked to Form field, but the Script Field is still filled in (with details not necessarily related).

    Is there a way (or what is the code to add to the script) which tests that if the Directors Signing Field is not populated with anything then the Script Field is blank but otherwise the result variable from the script is used?

    I know how to create if fields just not with Javascript (despite the sample code you provide).

    I guess what I wish to achieve:

    If Directors Signing Field is empty then result
    otherwise make Script Field blank

    Existing code in Script Field

    // Get the ID of the Form - click on the Form heading to the left
    // Then click on "ID" button on left
    // And assign to variable "directors_id"
    
    var directors_id = 'fld-b97b1fadf82f42e08b2f8be84b5a0bb9';
    
    // set list of records to variable "directors_record
    
    var new_identified_work_record = record.getFieldValue(directors_id);
    // var directors_record = record.getFieldValue(directors_id);
    
    // Test if there is a record
    if (new_identified_work_record.length >0) { 
    
    //Select the first reocrd 
    var first_new_identified_work_record = new_identified_work_record[0];
    
    // Assign record to variable
    var identification_details_newly_identified_work_address_id = 'fld-cf17026d0c4a46c492195b21ad872a7e';
    
    // var full_address_id = 'fld-9b8f0ecdd8b3422bb1bcbd4b4a9a2077';
    
    // Assign value of reocords to a variable
    
    var address = first_new_identified_work_record.getFieldValue(identification_details_newly_identified_work_address_id);
    
    // Put value of record into a result
    
    result = address	
    
    }
    
    // print out value of result into field
    result;
    Victor Warner
    Participant

    I am finding that if I type a space after a quote (double or single) causes Tap Forms to hang.

    For example

    var result = ‘ ‘;

    after I type the first quote ‘ and then press the space bar, Tap Form hangs (spinning beachball). This happens every time.

    This happens on both Macs I use.

    macOS 10.14.4 – Tap Forms 5.3.5

    #34148
    A Ibanez
    Participant

    I created a Time field (not datetime) and I want to set its value with a script.

    I have tried the following:

    
    inRecord.setFieldValue(broadcast_jst_id, "01:05");
    
    
    inRecord.setFieldValue(broadcast_jst_id, new Date("01:05"));
    

    Unfortunately after the script runs the field is blank.

    #34147
    A Ibanez
    Participant

    In the meantime, I think I’m gonna create a script that just finds all unique genres and puts them somewhere else so I can easily copy and paste them into the genres pick list. I want to use Comboboxes, checkboxes, and others for the things I want to keep in pick lists.

    #34146
    Brendan
    Keymaster

    I haven’t opened up the PickList object to the JavaScript API yet.

    Instead of using a Pick List though you could perhaps enable the “Use Auto-Complete” function? That way Tap Forms will build a popup menu of values already from the values you’ve already got in the field in that form.

    #34144
    A Ibanez
    Participant

    The script I’m writing to populate my anime database automatically pulls the genres and sets them in a text field separated by tags (Fantasy,Magic,Drama,Comedy). I’d like to add those four tags to a Genres Pick List. I created the pick list already, but I can’t seem to find a way to add anything to them with a script.

    I checked the documentation and couldn’t find any reference to interacting with picklists from the JavaScript API.

    I’m aware I can open my pick list and click the “+” button to add all the contents to the pick list and it will automatically split the string based on a comma and add them in, but my database is gonna have 700 records and I don’t wanna go through each of them manually. There is also the possibility that new genres will be added over time.

    #34137
    Brendan
    Keymaster

    Hi Andy,

    It’s actually easier than this.

    If you create a Default Value for your Website Address field like this:

    https://myanimelist.net/anime/[Mal ID]

    Then Tap Forms will automatically inject the value of the Mail ID field into the URL when you click the little globe button next to the Website Address field.

    Hope that’s an acceptable solution.

    You can also of course use a Script field to do this too by having the Script field write a URL for you into your MAL URL field.

    Thanks!

    Brendan

    #34134
    A Ibanez
    Participant

    Heya. Sorry for the unclear title, I will explain below.

    I’ve been using TapForms for years but I just realized how powerful it is with Calculations and Scripts. So I’m working on migrating an anime database to a new format.

    Here’s my situation.

    – I want to keep a numerical field called “MAL ID” that stores the ID of a series in myanimelist.net.
    – I want to generate a URL called “MAL URL” whose format would be “CONCAT(“https://myanimelist.net/anime/”, [MAL ID]”, where “MAL ID” is the value of the MAL ID field. This would for example create this URL: “https://myanimelist.net/anime/31240”
    – I’d like to store the value of the “MAL URL” field in a field of type “Web Site” called “Web Site” so I can click on it when I’m on my phone to visit it easier.

    I can generate the URL based on the MAL ID field, but I cannot figure out a way to bring the value of the “MAL URL” website to make it clickable in the “Web Site” field.

    To simplify my explanation, have a look at this screenshot:

    The MAL ID field is the only field that the user edits manually. Tapforms then generates the link to MyAnimeList using a Calculation field in “MAL URL”. Now I want to bring the value of MAL URL into “Web Site” keeping the “Web Site” field type.

    Is there any way to do this?

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

    Hi Kirk,

    Thanks for the added details. I’ll look into this further based on your description.

    However, at the moment with the latest macOS and Xcode versions, I’m having troubles compiling a third party library I use, so once I get that all resolved, then I’ll be able to dig into this issue. I may need to contact the third-party library developer to see if they can help. Unfortunately it’s the CouchbaseLite database engine I use which isn’t compiling anymore, so it’s a pretty important piece of code.

    Thanks,

    Brendan

    #34103

    In reply to: QR Code Question

    Brendan
    Keymaster

    Hi Eddzo,

    There’s no access controls like that in Tap Forms. So that part wouldn’t work.

    The only two places QR codes are used in Tap Forms is for searching for the value of the scanned QR code and for entering in the data of the scanned QR code.

    However, with a script, you could have Tap Forms take the value of a scanned barcode and do something with it such as call out to your server and do something there.

    If you look at the Scripting chapter, you’ll see an example of fetching from a movie library web service for the given barcode value. You can add a Field Script which will trigger the script when a barcode is scanned into a field.

    Thanks!

    Brendan

    #34102

    In reply to: Sorting by position

    Brendan
    Keymaster

    Hi Antonio,

    Yes, I do use CouchbaseLite for Tap Forms. And yes you’re right, they do have geo spatial queries. In fact, the Mac version uses that on the Map View to fetch records that are within a certain geographic area as defined by the zoom level of the map. But it still fetches the records according to the defined Sort Field settings, not by distance to some arbitrary coordinate.

    There’s no auto-run function for scripts outside of a Field script that gets run when you modify a field that the script references. You can setup a shortcut key to run a Form Script though. You would have to manually trigger that when you select the form. You can also add a Run Script button to a custom layout to run a script too.

    You might be able to write some JavaScript to call out to a web service to figure out the distance between two points and then update a distance field within Tap Forms and then sort by that. Either that or if there’s a distance algorithm in JavaScript you could use, such as the Levenshtein distance algorithm. But that only gives you the distance between two points ‘as the crow flies’.

    #34099

    In reply to: Sorting by position

    Antonio Calanducci
    Participant

    Hi Brendan,

    thank you for the reply.
    What type of database are you using behind the scene to store data locally? As I see you support CouchDB syncing, this let me think that you could use Couchbase mobile, that should support geospatial queries. But as you are mentioning indexes in your answer maybe it’s not the case (I read somewhere you used to use SQLite, but not sure if this applies to the macOS version too).

    I haven’t yet taken a look to the Javascript APIs: is there some hook to run a script at a given time? For example, if I can set a trigger on form loading, I could run a script that takes my current position, calculate the difference between my position and every fields’s position and populate a distance field, so I can sort the records by this field. Is this what you meant above as “separate distance function” ?

    I know this is not optimal, but at least I could solve my problem for the moment.
    thank you

Viewing 15 results - 2,446 through 2,460 (of 2,864 total)