Skip to main content

Notifications

Announcements

No record found.

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!

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Possible to have one field with two values?

    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

  • extersphere Profile Picture
    75 on at
    RE: Possible to have one field with two values?

    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!

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Possible to have one field with two values?

    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,467 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans