Custom Number Fomats

Viewing 3 reply threads
  • Author
    Posts
  • August 16, 2024 at 1:31 AM #51001

    Lorenzo Wood
    Participant

    Maybe I’m crazy but I’m surprised I haven’t found anything on here about this. I’m looking to track weight and power consumption of lists of equipment and trying to have number fields for lbs, amps, watts, etc and cant find a way to do this. I’d love some smart conversion features like being able to put in kg or oz and have it spit out the correct lbs but at the very least would like to be able to add a suffix

    Is this possible or am I making submitting a feature request?

    • This topic was modified 4 months, 1 week ago by Lorenzo Wood.
    • This topic was modified 4 months, 1 week ago by Lorenzo Wood.
    August 16, 2024 at 7:04 PM #51005

    Brendan
    Keymaster

    Hi Lorenzo,

    You could achieve this with a Calculation field.

    Tap Forms just has a pre-set list of different Number Formats to select from at the moment.

    So you could have a field where you enter in kgs and a Calculation field that spits out the conversion for you. And even adds a suffix if you like.

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

    Thanks,

    Brendan

    August 17, 2024 at 10:59 AM #51008

    Daniel Leu
    Participant

    Lorenzo, have a look at the attached document. It shows you how to convert a weight unit from metric to imperial and vice-versa. Each input field you want to convert needs a corresponding formatter field which is a field script. This script uses a common form script to perform the conversion.

    In the past, I already did a fraction converter, so I thought that this is a nice exercise to build upon that.

    Hope this helps!

    -Daniel

    Attachments:
    You must be logged in to view attached files.
    August 19, 2024 at 5:30 AM #51010

    JScottA
    Participant

    From Tap Forms 5 Assistant:

    To assist the forum member in tracking weight and power consumption with the ability to add units (like lbs, amps, watts, etc.) and potentially include smart conversion features, here’s how you can achieve this in Tap Forms:

    ### 1. **Creating Number Fields with Suffixes:**
    – Tap Forms allows you to create number fields where you can manually enter values like weight (lbs), power (watts), and current (amps). While Tap Forms doesn’t inherently allow you to add a suffix directly within a number field, you can work around this by using a **Text field** to store the number along with its unit. For example, you might have a field called “Weight” where you store “20 lbs”.

    ### 2. **Creating a Calculation Field:**
    – You can create a **Calculation field** that performs arithmetic operations on your numeric fields. For example, you could have fields for Weight (lbs), Current (amps), and Power (watts), and then use a calculation field to perform any necessary computations based on these values.

    – **Example**: If you have separate fields for weight in pounds (Weight_lbs) and kilograms (Weight_kg), you can use a calculation field to convert Weight_kg to pounds:
    `
    Weight_kg * 2.20462
    `

    – This will automatically calculate the weight in pounds whenever you enter a value in the Weight_kg field.

    ### 3. **Smart Conversion Using Scripts:**
    – Tap Forms supports JavaScript, which you can use to create more advanced calculations or conversions. For instance, you could write a script that allows the user to input weight in various units (kg, oz, lbs) and then convert it to the desired unit.

    – **Example Script**:
    `javascript
    var weight_kg = record.getFieldValue(‘field_kg’);
    var weight_lb = record.getFieldValue(‘field_lb’);
    if (weight_kg != null) {
    record.setFieldValue(‘field_lb’, weight_kg * 2.20462);
    } else if (weight_lb != null) {
    record.setFieldValue(‘field_kg’, weight_lb / 2.20462);
    }
    `

    This script checks if the weight is entered in kilograms and converts it to pounds, or vice versa. You can expand this script to handle other units like ounces.

    ### Reference Information:
    – For more details on setting up calculation fields and using JavaScript in Tap Forms, refer to **pages 29-37** in the manual, which cover **Calculation Fields** and **Script Fields** [oai_citation:1,1328_16794_en_1538683502.pdf](file-service://file-15C3MsaZPdU2JvfF2hiej31w).

    By following the steps above, the forum member can track and convert units effectively within Tap Forms.

Viewing 3 reply threads

You must be logged in to reply to this topic.