Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

allow users to add more values into power apps portal form?

Posted on by 100

Hello,

i have a dropdown column with few values and there is "Other" one of the value. So as soon as user select "Other" value from the drop-down another text box will pop-up on the form. it was working before on the form but all of a sudden not displaying the text box.  is there any idea what could be the issue?

$(document).ready(function () {
    MyFieldChanged();
    $('#custom_preference').on("change", MyFieldChanged);
});

function MyFieldChanged() {
  $("#custom_text").closest("tr").hide();
    var selectedValue = $('#custom_preference').val();
    if (!!selectedValue && selectedValue == 881990007) {
      $("#custom_text").closest("tr").show();
    }
    else {
      $("#custom_text").closest("tr").hide();
    }
}

3007.Capture.JPG_2D00_640x480-_2800_1_2900_.jpg

  • Rakki Profile Picture
    Rakki 100 on at
    RE: allow users to add more values into power apps portal form?

    Thanks Steve for your answer.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: allow users to add more values into power apps portal form?

    Hi Rakki,

    Based on your code, it should work if your logical name "#les_others" is correct. You could press f12 to check it.

    pastedimage1650937013919v1.png

    And I noticed that the other would show whatever your if condition is true or false.

    Please change to code like this:

    if(selectedValue && selectedValue == 100000007){
    console.log(true);
    $("#les_others").closest("tr").show();
    }
    else{
    console.log(false);
    $("#les_others").closest("tr").hide();
    }

    And you could know which branch is executed by the output in console. Please clear your cache to have a try.

  • Rakki Profile Picture
    Rakki 100 on at
    RE: allow users to add more values into power apps portal form?

    Hello Steve,

    Still "Others" text box not showing up on the form even though Other option value is getting "100000007" when selected from the drop-down as you can see in the below picture. what else causing the issue you think?

    Appreciated for your help.

    pastedimage1650899795450v1.png

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: allow users to add more values into power apps portal form?

    Hi Rakki,

    Based on the screenshot you provide, the issue should cause by your filed name is wrong. Please change $('#les_Perference').val() to $('#les_perference').val() at line426 in your screenshot.(The P should be lower case as the same as  it at the line419)

  • Rakki Profile Picture
    Rakki 100 on at
    RE: allow users to add more values into power apps portal form?

    Steve,

    appreciated for your reply. i was able to debug and noticed when i am selecting "Other" from drop-down is getting "undefined" value and getting into else condition to hide the text box. what could be the reason to get "undefined" value and how to resolve it?

    Thanks in advanced.

    0815.Capture.JPG

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: allow users to add more values into power apps portal form?

    Hi Rakki,

    You could add debugger; or console.log(object) in you code. Something like this:

    $(document).ready(function () {
        MyFieldChanged();
        $('#custom_preference').on("change", MyFieldChanged);
    });
    
    function MyFieldChanged() {
      debugger;
      $("#custom_text").closest("tr").hide();
      console.log($("#custom_text").closest("tr"));
        var selectedValue = $('#custom_preference').val();
        if (!!selectedValue && selectedValue == 881990007) {
          $("#custom_text").closest("tr").show();
        }
        else {
          $("#custom_text").closest("tr").hide();
        }
    }

    Then press F12 to debug or view the console.

  • Rakki Profile Picture
    Rakki 100 on at
    RE: allow users to add more values into power apps portal form?

    Hello Steve,

    Thanks for your reply. alert function is working within JavaScript but text field not displaying. i am using advanced form within the wizard and entering the JS into form options.

    so how can i debug the JavaScript which residing into CRM Backend?

    pastedimage1650489440530v1.png

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: allow users to add more values into power apps portal form?

    Hi Rakki,

    I tested your code on my side and it could work fine.

    Below is my test:

    1. Add JS code to my basic form.

    pastedimage1650348265687v1.png

    Result:

    perferfance.gif

    You can try the following points:

    1. Clear the cache of your browser and reopen your portal.

    2. Press F12 to see there is any error.

    3. Debugger your code to see that does it run well.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans