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,521 through 2,535 (of 2,950 total)
  • Author
    Search Results
  • #34363
    Heath Goodman
    Participant

    Hi Brendan- The invoice tracking template is a great start. I was just wondering how I could turn it into like a shopping cart/estimate/invoice function to tweak it so that when we go into Order Items that we can have either a button or (autofill feature) to choose from the products table any product to auto populate the form with the correct corresponding product info, i.e., product name, description and price, whether taxable, (and able to order the same product if needed, essentially another line item of the same product with perhaps different quantities entered) which then updates totals- essentially I wanted to turn your invoice template into a shopping cart/Invoice/Estimate functionality. Is Tapforms capable of this? Thanks.

    #34336
    Victor Warner
    Participant

    Brendan,

    Thank you for the examples (and after a lot of examination at https://www.w3schools.com) I think I have found the JavaScript equivalent:

    var number_of_pages_id = 'fld-b6882198382f4b368dccfa874e69a563';
    
    var number_of_pages = record.getFieldValue('fld-b6882198382f4b368dccfa874e69a563');
    
    var extract_from_document_id = 'fld-e3540b375b0f43cb97f4ea84a2705885';
    
    var extract_from_document = record.getFieldValue('fld-e3540b375b0f43cb97f4ea84a2705885');
    
    result = '';
    
    if (number_of_pages == 1 && extract_from_document == 1) {
    	
    result = "of an extract (the front of the first page, comprising " + record.getFieldValue(number_of_pages_id) + " A4 sheet of paper)";
    
    } else if (number_of_pages == 1 && extract_from_document == 0) {
    		
    result = "(comprising " + record.getFieldValue(number_of_pages_id) + " A4 sheet of paper)";
    	
    } else if (number_of_pages > 1 ) {
     
    result = "(comprising " + record.getFieldValue(number_of_pages_id) + " A4 sheets of paper)";
    
    } else {
    
    result = '';
    
    }
    
    result;
    
    #34319
    Brendan
    Keymaster

    Well you can do nested if statements really easily in JavaScript.

    if (numberOfPages == 1) {
       if (extractFromDocument == 1) {
          // do something
       }
    }

    But this is also the equivalent of:

    if (numberOfPages == 1 && extractFromDocument == 1) {
       // do something
    }
    #34316
    Victor Warner
    Participant

    Brendan,

    Could you help me if how to do an IF statement within an IF statement in JavaScript based on the code I set out in my original post? I have tried based on the code for the Calculation field but it does not appear to work (most probably because of lack of knowledge of Javascript).

    [Number of pages] is a text field.
    [Extract from document] is a Check Mark field.

    Any help would be very gratefully received (even if it is just the basic outline of how to construct the JavaScript).

    #34315
    Brendan
    Keymaster

    It would seem that the ( and ) characters are being interpreted by the Math parser as parentheses for the functions and order of operations even when they’re within double-quotes. I would need to add support to let you escape them like you can a comma, semi-colon, or double-quote.

    A workaround for now I would suggest is to use a Script Field instead of a Calculation field to do the same thing. It will also be easier to read in JavaScript than in the formula.

    #34309
    Rob Young
    Participant

    I want to populate a task list form (form A) from a reusable set of activities for things like preparing to travel and setting up camp with my travel trailer and tow vehicle. I created a form (form B) with task fields and created several records representing activities. I created the task list form with a date field and a table (columns names matching the field names in form B). I’ve successfully manually loaded the table in form A with the fields and filtered records from form B. I would like the table in form A to be automatically loaded with a filtered and sorted set of rows from form B when a new record is added to form A. Is this a job for a script? Is there a script example I can use to accomplish this?

    Thanks in advance for any help!

    #34299
    Brendan
    Keymaster

    Hi Grischa,

    You can do queries against the data stored at IBM Cloudant. They have a whole REST API for that. The nice thing about that is you don’t need Tap Forms running to do that.

    I do have AppleScript support in Tap Forms which would let you execute a Form Script from an AppleScript. But in testing it I just realized I broke it when I added Siri Shortcuts support on iOS. In order to provide Siri Shortcuts support I had to split my model objects into their own framework and there was a dependency that I commented out which I forgot to add back in which broke AppleScript support. I’ve just fixed it now actually.

    One option you might consider is using the Export Tap Forms Archive command if you need JSON output. That generates a .tfarc file which has all the data in it stored in a data.json file within the .tfarc file. That’s just a zip file with a renamed file extension. So you can rename it to .zip and then unzip it and you’ll see the data.json file within it. Now it would be up to you to get the data out of it that you need. Might not be easy though.

    Or if you write some JavaScript code to fetch records data, you can then format that as JSON within JavaScript and then use the Utils.postJsonToUrl(json_string, url); function. There’s not much to it. You just create a JSON string, provide it a URL, then call that function. It will return a dictionary of results. So your web service should return a dictionary for it to use. If you had your own web service you could use this to send it data from Tap Forms. I’m not sure what web application facilities you have available to you though, so I don’t know if this is feasible or not.

    Thanks,

    Brendan

    A Ibanez
    Participant

    I’m dealing with a rather sensitive API that times out very often for me. This API returns images and I want to add those images to my forms. To do this I’m iterating over all the records and adding them. But due to the timeouts, sometimes my images don’t get added.

    To go around this issue i’d like to count the number of images in a Photo field and if it’s > 0, skip it.

    So far I haven’t even been able to access the Photo field. tt.getFieldValue(photo_id_charactersform); returns undefined.

    I have a workaround for this but i’d like to avoid it if possible, as it requires me to manually keep track of how many images a record field has.

    #34295
    Grischa Dallmer
    Participant

    Greetings,

    this is an advanced question.

    I have a complex database with events which I manually export in certain formats to publish them on three different websites.

    As I know JavaScript, I would like to somehow retrieve my data as JSON, so I can build web views and display the data according to my needs.

    My database is synced with IBM Cloudant.

    I saw in the Tap Forms documentation that there is a util called postJsonToUrl but I haven’t found any further documentation.

    Do I have to deal with the API of cloudant and complicated SQL requests to retrieve my data or can I use the TapForms API, create a JSON and access it from outside?

    Thanks in advance,

    Grischa

    #34281
    Victor Warner
    Participant

    I think I have solved the problem:

    I added near the top of the script:

    result = '':

    and the error message disappeared and the script runs properly (and the now the request for help with the if statement become superfluous (at least in my limited testing).

    Victor Warner
    Participant

    I think I have solved the problem:

    I added near the top of the script:

    result = '':`

    and the error message disappeared and the script runs properly.

    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;
Viewing 15 results - 2,521 through 2,535 (of 2,950 total)