web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

Possible to have one field with two values?

(0) ShareShare
ReportReport
Posted on by 75

I have a field called 'Length' and I want to have two boxes to be filled in with two values, one for feet and then another for inches. Is there an OOB way to enable this?


Thank you!

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    There is no OOB way to do this, so I suggest that you could put two fields on the form named Feet and Inches, and when you enter value in one of them, the another value will be calculated and filled in the field automatically.

    To do this, we need use JS code. I wrote two JS functions, and please add "getInches" on Feet field onchange event and add "getFeet" on Inches field onchange event.

    function getInches(executionContext){
        var formContext=executionContext.getFormContext();
        var feet=formContext.getAttribute("new_feet").getValue();
        var inches=parseFloat(feet)*12;
        formContext.getAttribute("new_inches").setValue(String(inches));
    }
    
    
    function getFeet(executionContext){
        var formContext=executionContext.getFormContext();
        var inches=formContext.getAttribute("new_inches").getValue();
        var feet=parseFloat(inches)/12;
        formContext.getAttribute("new_feet").setValue(String(feet));
    }
    
     

    pastedimage1587452829075v2.png

    pastedimage1587452808805v1.png

    Save and publish.

    Then we go back to the form, when we fill value in Feet field, there will be value filled in Inches automatically, And vice versa.

    Fill in Feet:

    pastedimage1587452924309v3.png

    Fill in Inches:

    pastedimage1587452951081v4.png

    Hope it helps.

    Best Regards,

    Leo

  • extersphere Profile Picture
    75 on at

    Hi there, thank you for that explanation! that answer definitely makes sense but I was thinking more of a field for total length and then the user is allowed to enter a value for feet AND inches. So that if the length is 5 feet and 10 inches, there are two fields for which to enter data but the true value for that field would be the summation of the two fields behing the scenes. So the length would be 70 inches stored in the system which then could be converted as 5 ft 10 inches displayed to the user.

    Thank you!

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Thanks for your details.

    You could add another text field to show the complete length with both inch and feet by JS splicing.

    For example, I create a new text field named "wholeLength", just add the following code the function "getFeet" in my last answer.

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:9ffc57fa-9bbf-4ecd-b1f6-aa63531fe9cc:type=javascript&text=%20%20%20%20var%20inches2%3DparseInt%28inches%29%2512%3B%0D%0A%20%20%20%20var%20feet2%3DparseInt%28inches%29%2F12%3B%0D%0A%20%20%20%20var%20length%3Dfeet2%2B%22%20feet%20%22%2Binches2%2B%22%20inches%20%22%3B%0D%0A%20%20%20%20formContext.getAttribute%28%22new_completelength%22%29.setValue%28String%28length%29%29%3B]

    And add the following code in "getInches" function.

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:9f2538c5-d91f-4926-a49c-4a71ea399f73:type=javascript&text=formContext.getAttribute%28%22new_completelength%22%29.setValue%28inches%2B%22%20inches%22%29%3B]

    pastedimage1587957683284v1.png

    Regards,

    Leo

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
NeerajPawar Profile Picture

NeerajPawar 31

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 23 Super User 2026 Season 1

#3
Encore Business Solutions Profile Picture

Encore Business Sol... 14

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans