web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Webresource - Value is not an array

(0) ShareShare
ReportReport
Posted on by 35

Let me say up front....I am unfamiliar with arrays and do not know/understand the concept and how to define or create them

I have a "partners" type field from a custom activity that I am attempting to hide based on a Mandated (value "0") or Non-mandated (value "1") option set field.  Using the following code in on-load and on-change web-resource, I keep getting the error message "Value is not an array".  Can someone please help.

function HideMandate_Lookup() {

     var mandated = Xrm.Page.getAttribute("statemandated").getValue();
    
     if (mandated != 0) {
       Xrm.Page.ui.controls.get("partners").setVisible(false)
       Xrm.Page.getAttribute("partners").setValue(false);
  
 }
 
    else if (mandated == 0) {
       Xrm.Page.ui.controls.get("partners").setVisible(true)
       Xrm.Page.getAttribute("partners").setValue(true);
    
 }
      }

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi,

    You could try a business rule instead.

    Regards,

    Ketan

  • Suggested answer
    Saad Kabarousse Profile Picture
    734 on at

    Hello,

    Is "partners" field is a multiple select value field? be cause if so Xrm.Page.getAttribute("statemandated").getValue() will return an Array and since you are comparing it to a number i think that may cause that error.

    I Hope this helps :)

  • ajyendra Profile Picture
    1,738 on at

    Hi,

    1)Did you debug that code and find that what value you get in mandated variable ?

    2) You have any function other than this HideManadate_lookup function in same web-resource file. may be it will occur this issue.

    3) Add Semicolon too in Xrm.Page.ui.controls.get("partners").setVisible(false) and Xrm.Page.ui.controls.get("partners").setVisible(true) for just code ethics.

    4) Any other function call in page load or onchange  other than this.

    Let me know it helps or not What value you are getting in mandated variable when you debug

    Thanks

    Ajyendra

  • sscinokc Profile Picture
    35 on at

    Ketan -  Tried that first.  However, "Party List" fields are not available to select from in Business Rules.

  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi,

    You cannot set true/false in a partylist.

    Refer below example.

       var Partners = Xrm.Page.getAttribute("partners");

       var value = new Array();

       value[0] = new Object();

       value[0].id = "67cf851f-165a-e611-80bb-a4934caa8811";

       value[0].name = "Helpdesk";

       value[0].entityType = "systemuser";

       Partners.setValue(value);

    If you want to clear then use below.

    Xrm.Page.getAttribute("partners").setValue(null)

    Regards,

    Ketan

  • sscinokc Profile Picture
    35 on at

    Ketan -

    Thanks for the response.  I understood your comment about true/false not allowed in partylist.  The rest was unfamiliar language to me at this point and I will have to do further "learning" about arrays to know how to apply.

    In the mean time, I heard elsewhere someone having this difficulty and elected to apply their solution of simply placing the partylist in its own Section, and just hid the Section based on my criteria.  That seemed to do the trick for now until I can learn more about adding an array.

    Thanks for your help.

  • Verified answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    Hi, 
     
    You need to pass an Integer value for SetValue. 
  • sscinokc Profile Picture
    35 on at

    Thanks, Kalpavruksh, for pointing me in the right direction.  It helped me understand that I did not require the Xrm.Page.getAttribute("partners").setValue line at all.  Once I took those lines out to be the following, it worked perfectly.  Thanks again.

    function HideMandate_Lookup() {

        var mandated = Xrm.Page.getAttribute("statemandated").getValue();

        if (mandated != 0) {

          Xrm.Page.ui.controls.get("partners").setVisible(false)

     }

        else if (mandated == 0) {

          Xrm.Page.ui.controls.get("partners").setVisible(true)

     }

         }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans