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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

i want to Create an Array that contain all fields that gonna be hidden CRM

(0) ShareShare
ReportReport
Posted on by 5

i want to use an array that contain all the fields and it will be hidden and use for loop to do it

Inside the CRM MS i don't know how please i need help

function hideShowPicklist(executionContext) {

var RequiredField = GetAttributeValue(executionContext, "requiredtype");

var ProcessField = GetAttributeValue(executionContext, "processtypecode");


if (RequiredField == "0" && ProcessField == "4" || ProcessField == "5") {

    // it will Show the fields and set them as Required 
    SetAttrsVisibility(executionContext, "name", ",", true);

    SetAttrsVisibility(executionContext, "managername", ",", true);

    SetAttrsVisibility(executionContext, "fordealexecution", ",", true);

    SetAttrsVisibility(executionContext, "registrationaddress", ",", true);

  }

i want to code to be very short by using array and for loop

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Something like that?

    var RequiredField = GetAttributeValue(executionContext, "requiredtype");
    
    var ProcessField = GetAttributeValue(executionContext, "processtypecode");
    
    if (RequiredField == "0" && ProcessField == "4" || ProcessField == "5") {
    	var fields = ["name", "managername", "fordealexecution", "registrationaddress"];
    	fields.forEach(function(field) {
    		SetAttrsVisibility(executionContext, field, ",", true);
    	});
    }

  • Abeer Abdualaziz Profile Picture
    5 on at

    I will explain so You can get my point

    I want an Array that contain the fields that i want to hide under conditions if the user has  select option 0 And Select 4 or 5  

    here the loop must work.

    why i want to use array and loop to make my code very short.

    please help me

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I provided the code. It doesn't work?

  • Abeer Abdualaziz Profile Picture
    5 on at

    Yeah its work but if try to add else if {RequiredField == "0"}

    and i want show only 3 index inside the array it gave me an error

    please any way i can contact you ?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I don't provide free consultancies outside of the forum.

    If you have the code that doesn't work - put it here.

  • Abeer Abdualaziz Profile Picture
    5 on at

    function hideShowPicklistNDA(executionContext) {

       var ndaRequiredField = GetAttributeValue(executionContext, "ndarequiredtypecode");

      var investmentProcessField = GetAttributeValue(executionContext, "investmentprocesstypecode");

    var NPA = ["fundname", "fundmanagername", "expectedduedatefordealexecution", "officialregistrationaddress"];

    if (ndaRequiredField == "0" && investmentProcessField == "4" || investmentProcessField == "5") {

    var NPA = ["fundname", "fundmanagername", "expectedduedatefordealexecution", "officialregistrationaddress"];

    NPA.forEach(function (field) {

    SetAttrsVisibility(executionContext, field, ",", true);

    SetAttrsRequiredLevel(executionContext, field, ",", "required");

    });

    } else if (ndaRequiredField == "0" ) {

    SetAttrsVisibility(executionContext, field, ",", false);

    }

    i want to use the array outside the if condition also the for loop

    in the else if i want to hide some fields that inside the array

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Try this:

    function hideShowPicklistNDA(executionContext) {
    
        var ndaRequiredField = GetAttributeValue(executionContext, "ndarequiredtypecode");
    
        var investmentProcessField = GetAttributeValue(executionContext, "investmentprocesstypecode");
    
        var NPA = ["fundname", "fundmanagername", "expectedduedatefordealexecution", "officialregistrationaddress"];
    
        if (ndaRequiredField == "0" && investmentProcessField == "4" || investmentProcessField == "5") {
            NPA.forEach(function(field) {
                SetAttrsVisibility(executionContext, field, ",", true);
                SetAttrsRequiredLevel(executionContext, field, ",", "required");
            });
    
        } else if (ndaRequiredField == "0") {
            NPA.forEach(function(field) {
                SetAttrsVisibility(executionContext, field, ",", false);
            });
        }
    }

  • Abeer Abdualaziz Profile Picture
    5 on at

    its worked !! thank you so much  , but if want to call one of the values of the array how ?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I'm sorry, I don't understand what you mean.

  • Abeer Abdualaziz Profile Picture
    5 on at

    Okay sorry  

    in the condition here i want call an index from the array i don't want it to be all hidden in this condition i only want two show "fundname", "fundmanagername"

    else if (ndaRequiredField == "0") {

           NPA.forEach(function(field) {

               SetAttrsVisibility(executionContext, field, ",", false);

           });

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 153

#2
ManoVerse Profile Picture

ManoVerse 147 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans