Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CRM 4.0 javascript error

Posted on 2009-04-06
1
Medium Priority
?
694 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
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part I
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…
Suggested Courses

877 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