Skip to main content
Dynamics 365 general forum
Answered

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

editSubscribe (0) ShareShare
ReportReport
Posted on by 75

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 75 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 UG Leader 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 75 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 UG Leader 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 75 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 UG Leader 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 75 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 UG Leader 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.

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans