Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CRM 4.0 javascript error

Posted on 2009-04-06
1
Medium Priority
?
690 Views
Last Modified: 2012-05-11
This code when run as an onchange event on the field works fine when I paste it into the onload for the form it always throws an error for this section:
{
            oTempArray[iIndex] = ocategoryofservice.originalPicklistOptions[i];
            iIndex++;
      }

FULL CODE BELOW

var ocasetypecode = crmForm.all.casetypecode ;

var iStartIndex = -1;
var iEndIndex = -1;

switch (ocasetypecode .SelectedText)
{
      case "Training":
            iStartIndex = 1;
            iEndIndex = 14;
            break;

      case "Technical Assistance":
            iStartIndex = 15;
            iEndIndex = 31;
            break;

                       case "Resource Development":
            iStartIndex = 32;
            iEndIndex = 34;
            break;

                       case "Advocacy":
            iStartIndex = 35;
            iEndIndex = 36;
            break;



}

var ocategoryofservice= crmForm.all.new_categoryofservice;

if (iStartIndex > -1 &&  iEndIndex > -1)
{
      // Create a new array, which will hold the new picklist options
      var oTempArray = new Array();

      // Initialize the index for the temp array
      var iIndex = 0;

            for (var i = iStartIndex; i <= iEndIndex; i++)
      {
            oTempArray[iIndex] = ocategoryofservice.originalPicklistOptions[i];
            iIndex++;
      }

            ocategoryofservice.Options = oTempArray;

            ocategoryofservice.Disabled = false;
}
else
{
            ocategoryofservice.DataValue = null;
      ocategoryofservice.Disabled = true;
}
0
Comment
Question by:biotec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
t-joe earned 2000 total points
ID: 24085310
Hello biotec,

have you seen this post: http://social.msdn.microsoft.com/Forums/en-US/isv/thread/f0f8ff49-30f2-46e2-8174-213a7810c357/

If the error is regarding the originalPicklistOptions attribute then it seems you have to set it earlier.

To clarify, "Marius August" wants you to leave the original code in the onchange event, and then put his code in onload. In his code he makes a manual call to the onchange event with the call new_sector_onchange0();
Since your field is called casetypecode, your call should be casetypecode_onchange0();

It should also be possible to keep all the code in the onload event, then you will have to declare your code in a separate function and call that instead.

Let me know if any of this helps!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Automatically creating a Trello card using data from a Microsoft Dynamics CRM record turned out to be an easy project that yielded great results.  Here's how I did this for an internal team at General Code.
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question