Solved

CRM 4.0 javascript error

Posted on 2009-04-06
1
685 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

751 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