web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    I provided the code. It doesn't work?

  • Abeer Abdualaziz Profile Picture
    5 on at
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

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

  • Abeer Abdualaziz Profile Picture
    5 on at
    RE: i want to Create an Array that contain all fields that gonna be hidden CRM

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 125

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 110 Super User 2025 Season 2

#3
Erin Lubben Profile Picture

Erin Lubben 73

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans