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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

This is regarding the closed forum - https://community.dynamics.com/365/f/dynamics-365-general-forum/439055/how-to-show-the-field-only-if-users-selects-others-from-the-multi-choice-column-using-js-script/1206929 , had some error in that code

(0) ShareShare
ReportReport
Posted on by

Hello    This is regarding the closed forum - community.dynamics.com/.../1206929

i was testing the form and everything is working fine used the same code you had given, but just had one issue when I select some option in multi choice column and then I remove it , I'm getting the below error, if I select again some options then it will work properly.

when I open the new form then i will not receive any error, only when i select option and remove all options then i get this error, basically when i select something and then i remove it only if field is blank i get error, may something to do with this line not sure - if (selectedOptions.filter(i => i.value === 100000005).length > 0)

6116.error1.jpg

error message -Cannot read properties of null (reading 'filter')Session Id: e363e5ac-3692-4724-a98c-d9c5b10ff1b7Correlation Id: 7aa5f389-8056-485d-ac0a-cb1a033b5facEvent Name: onchangeFunction Name: ShowhidecoulmnenvWeb Resource Name: azmdc_HideIntendedEnvironmentOther.jsSolution Name: ActivePublisher Name: DefaultPublisherdevrccTime: Wed Nov 10 2021 11:09:52 GMT+0530 (India Standard Time)

when i downloaded the error log- 

TypeError: Cannot read properties of null (reading 'filter')
at Showhidecoulmnenv (https://.crm4.dynamics.com/%7b637721179470000131%7d/webresources/azmdc_HideIntendedEnvironmentOther.js:8:25)
at y._executeFunctionInternal (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:1980:5296)
at y.execute (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:1980:3765)
at https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:147:26335
at i (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:308:88)
at ee._executeIndividualEvent (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:147:26309)
at ee._executeEventHandler (https:/.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:147:23314)
at Object.execute (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:147:22742)
at N._executeSyncAction (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:923:692)
at N._executeSync (https://.crm4.dynamics.com/uclient/scripts/app.js?v=1.4.3368-2110.2:923:419)

Error Details:
Event Name: onchange
Function Name: Showhidecoulmnenv
Web Resource Name: azmdc_HideIntendedEnvironmentOther.js
Solution Name: Active
Publisher Name: DefaultPublisherdevrcc

code used - same has you have given

function Showhidecoulmnenv(executionContext) {
    var formContext = executionContext.getFormContext();
    var raiseRequest = formContext.getAttribute("azmdc_intendeduseenvironment");

    //Returns Array of Selected OptionSet Values, example [1001,1002,1005 ]
    var selectedOptions = raiseRequest.getSelectedOption();

    if (selectedOptions.filter(i => i.value === 100000003).length > 0) {
        formContext.getControl('azmdc_intendeduseenvironmentother').setVisible(true);
    }

    else {
        formContext.getControl('azmdc_intendeduseenvironmentother').setVisible(false);
    }
}

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi psk_12,

    Through my test, same error will appear, which is because the intendeduseenvironment  field value is null.

    You need add another new condition before original condition, which can specify the intendeduseenvironment field value is null or not.

    function Showhidecoulmn(executionContext) {
        var formContext = executionContext.getFormContext();
        var raiseRequest = formContext.getAttribute("new_intendedproductusers");
    
        //Returns Array of Selected OptionSet Values, example [1001,1002,1005 ]
        var selectedOptions = raiseRequest.getSelectedOption();
        if (selectedOptions != null) {
            if (selectedOptions.filter(i => i.value === 100000005).length > 0) {
                formContext.getControl('new_intendedproductusersother').setVisible(true);
            }
            else {
                formContext.getControl('new_intendedproductusersother').setVisible(false);
            }
        }
    }

  • Community Member Profile Picture
    on at

    Hello

    Thank so much for the prompt response.

    This worked perfectly.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 91

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 72 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 69

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans