[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

CRM 4.0 Dynamics error on javascript for onload when resolving case

Asked by biotec in Microsoft Dynamics, JavaScript

Tags: CRM 4.0, Dnymanics, javascript

I was told to add the following code in a previously posted question to the form onload but when I add it to the bottom of the already existing code I get a weird error that pops up when trying to resolve the case. The code is listed below I'll remark where the new code is that causes the error:

crmForm.all.tab1Tab.style.display = "none"; //hide
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;

// Only enable the dynamic picklist on a Create or Update form.  Disabled and
// read-only forms are not editable and so do not require dynamic picklists.
switch (crmForm.FormType)
{
      case CRM_FORM_TYPE_CREATE:
      case CRM_FORM_TYPE_UPDATE:

            // Get a reference to the Sub-Industry picklist element for later use
            var ocategoryofservice = crmForm.all.new_categoryofservice;


            // Cache the original picklist "Options" array in an "expando" on the
            // element.  We will use this original list to dynamicly re-build the picklist
            // based on the Industry the user selects.
            ocategoryofservice.originalPicklistOptions = ocategoryofservice.Options;

            // If there is not an Industry selected, we just need to disable the
            // Sub-Industry.  As soon as the user selects an Industry, we will
            // re-enable the Sub-Industry picklist.
            if (crmForm.all.casetypecode.DataValue == null)
            {
                  ocategoryofservice.Disabled = true;
            }
            else
            {
                  if(ocategoryofservice.DataValue == null)
                  {
                        // There is an industry value already selected, but not a subindustry.
                        // Limit the available options to what is valid for the currently
                                // selected Industry value. The code to do this already exists in the
                                // Industry Picklist's onchange event. Re-use that code by manually
                                // firing the event.
                        casetypecode_onchange0();
                  }
            }

      break;
}

// Insert this function into your form
// OnLoad event.
//CalcHours = function() {
 
//    MinsWorked = crmForm.all.crihb_timespentmin.SelectedText;
//    if (MinsWorked == null)
//   MinsWorked = ".00";
//    TotalWorked = crmForm.all.crihb_timespenthrs.DataValue + MinsWorked;
//    crmForm.all.crihb_totalhours.DataValue = parseFloat(TotalWorked);
 
//} // CalcHours function


CalcHours = function() {


MinsWorked = crmForm.all.crihb_timespentmin.SelectedText;
    if ((MinsWorked == null) || (MinsWorked == "")) {
        MinsWorked = "0"; }
    MinsFractWorked = parseFloat(MinsWorked)/60;
    TotalWorked = crmForm.all.crihb_timespenthrs.DataValue + MinsFractWorked;
    crmForm.all.crihb_totalhours.DataValue= parseFloat(TotalWorked);
 
} // CalcHours function

var currentDate = new Date();

if(crmForm.FormType == 1)
{
  crmForm.all.new_startdate.DataValue = currentDate;
}

if(crmForm.FormType == 2 && crmForm.all. new_startdate.DataValue == null)
{
  crmForm.all. new_startdate.DataValue = currentDate;
}

THE CODE BELOW CAUSES PROBLEMS

// Get the Industry Element, since this code is re-used by the form's onload event
// we can not rely on the event.srcElement to have the approriate element.
var ocasetypecode = crmForm.all.casetypecode ;

// Initialize the Sub-Industry indexes
var iStartIndex = -1;
var iEndIndex = -1;

// Depending on what the user selects in the Industry picklist, we will select
// a range of options in the Sub-Industry picklist to display.
//
// For the purposes of this sample, it is assumed that the display text of each
// Industry will be known and will not be localized.  We have also ordered the
// options in the Sub-Industry picklist so that they are group sequentially per
// Industry.  This allows the code to simply define start and stop Sub-Industry
// indexes for each Industry.
switch (ocasetypecode .SelectedText)
{
      case "Training":
            iStartIndex = 1;
            iEndIndex = 12;
            break;

      case "Technical Assistance":
            iStartIndex = 13;
            iEndIndex = 26;
            break;

                       case "Resource Development":
            iStartIndex = 27;
            iEndIndex = 29;
            break;

                       case "Advocacy":
            iStartIndex = 30;
            iEndIndex = 31;
            break;



}

// Get a reference to the Sub-Industry picklist element for later use
var ocategoryofservice= crmForm.all.new_categoryofservice;

// If the indexes where set, update the Sub-Industry picklist
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;

      // Now loop through the original Sub-Industry options, pull out the
      // requested options a copy them into the temporary array.
      for (var i = iStartIndex; i <= iEndIndex; i++)
      {
            oTempArray[iIndex] = ocategoryofservice.originalPicklistOptions[i];
            iIndex++;
      }

      // Reset the Sub-Industry picklist with the new options
      ocategoryofservice.Options = oTempArray;

      // Enable the Sub-Industry picklist for the user
      ocategoryofservice.Disabled = false;
}
else
{
      // The user has selected an unsupported Industry or no Industry
      ocategoryofservice.DataValue = null;
      ocategoryofservice.Disabled = true;
}
[+][-]03/17/09 04:32 AM, ID: 23906678Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Microsoft Dynamics, JavaScript
Tags: CRM 4.0, Dnymanics, javascript
Sign Up Now!
Solution Provided By: crm_info
Participating Experts: 1
Solution Grade: A
 
[+][-]03/16/09 03:54 PM, ID: 23903305Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/16/09 07:25 PM, ID: 23904254Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/17/09 08:35 PM, ID: 23915363Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625