Cannot add 'New Opportunity Product' to an Opportunity in Microsoft CRM 4

In Microsoft CRM 4, when I open an Opportunity, goto 'Products' and click on 'New Opportunity Product' I get 'Error on page' showing up in the bottom status area of my browser.

Products will not add to the opportunity and when I close the opportunity window an error dialog window pops up and tells me that CRM has encountered an error.

I have sent the error off to Microsoft and got no response, when I view the data sent to Microsoft I see this:

Microsoft Dynamics CRM Error Report Contents

<CrmScriptErrorReport>
  <ReportVersion>1.0</ReportVersion>
  <ScriptErrorDetails>
      <Message>&#39;crmForm.pricelevelid.DataValue&#39; is null or not an object</Message>
      <Line>67</Line>
      <URL>/ReactiveMedia&#47;sfa&#47;opps&#47;edit.aspx&#63;id&#61;&#123;D50A09D2-95B3-DD11-AB3B-0019B9DD22FE&#125;</URL>
      <PageURL>/ReactiveMedia&#47;sfa&#47;opps&#47;edit.aspx&#63;id&#61;&#123;D50A09D2-95B3-DD11-AB3B-0019B9DD22FE&#125;&#35;</PageURL>
      <Function>locCustomAddRelatedToNonForm&#40;iTypeToAdd, createFromType, createFromId, additionalAttributes&#41;</Function>
      <CallStack>
        <Function>locCustomAddRelatedToNonForm&#40;iTypeToAdd, createFromType, createFromId, additionalAttributes&#41;</Function>
      </CallStack>
  </ScriptErrorDetails>
  <ClientInformation>
      <BrowserUserAgent>Mozilla&#47;4.0 &#40;compatible&#59; MSIE 7.0&#59; Windows NT 6.0&#59; SLCC1&#59; .NET CLR 2.0.50727&#59; Media Center PC 5.0&#59; .NET CLR 3.0.04506&#41;</BrowserUserAgent>
      <BrowserLanguage>en-us</BrowserLanguage>
      <SystemLanguage>en-au</SystemLanguage>
      <UserLanguage>en-au</UserLanguage>
      <ScreenResolution>1280x800</ScreenResolution>
      <ClientName>Web</ClientName>
  </ClientInformation>
  <ServerInformation>
    <OrgLanguage>1033</OrgLanguage>
    <OrgCulture>3081</OrgCulture>
    <UserLanguage>1033</UserLanguage>
    <UserCulture>1033</UserCulture>
    <OrgID>&#123;50640F2F-87AA-4703-A6CB-B9CCDB26AD11&#125;</OrgID>
    <UserID>&#123;D7D30B55-5D9C-DA11-85C9-0013208EF692&#125;</UserID>
    <CRMVersion>4.0.7333.3</CRMVersion>
  </ServerInformation>
</CrmScriptErrorReport>

<CrmScriptErrorReport>
  <ReportVersion>1.0</ReportVersion>
  <ScriptErrorDetails>
      <Message>Could not complete the operation due to error 80020101.</Message>
      <Line>220</Line>
      <URL>/ReactiveMedia&#47;sfa&#47;opps&#47;areas.aspx&#63;oId&#61;&#37;7bD50A09D2-95B3-DD11-AB3B-0019B9DD22FE&#37;7d&#38;oType&#61;3&#38;security&#61;852023&#38;tabSet&#61;areaProducts</URL>
      <PageURL>/ReactiveMedia&#47;sfa&#47;opps&#47;areas.aspx&#63;oId&#61;&#37;7bD50A09D2-95B3-DD11-AB3B-0019B9DD22FE&#37;7d&#38;oType&#61;3&#38;security&#61;852023&#38;tabSet&#61;areaProducts</PageURL>
      <Function>function anonymous&#40;&#41;&#10;&#123;&#10;window.execScript&#40;action&#41;&#10;&#125;</Function>
      <CallStack>
        <Function>function anonymous&#40;&#41;&#10;&#123;&#10;window.execScript&#40;action&#41;&#10;&#125;</Function>
      </CallStack>
  </ScriptErrorDetails>
  <ClientInformation>
      <BrowserUserAgent>Mozilla&#47;4.0 &#40;compatible&#59; MSIE 7.0&#59; Windows NT 6.0&#59; SLCC1&#59; .NET CLR 2.0.50727&#59; Media Center PC 5.0&#59; .NET CLR 3.0.04506&#41;</BrowserUserAgent>
      <BrowserLanguage>en-us</BrowserLanguage>
      <SystemLanguage>en-au</SystemLanguage>
      <UserLanguage>en-au</UserLanguage>
      <ScreenResolution>1280x800</ScreenResolution>
      <ClientName>Web</ClientName>
  </ClientInformation>
  <ServerInformation>
    <OrgLanguage>1033</OrgLanguage>
    <OrgCulture>3081</OrgCulture>
    <UserLanguage>1033</UserLanguage>
    <UserCulture>1033</UserCulture>
    <OrgID>&#123;50640F2F-87AA-4703-A6CB-B9CCDB26AD11&#125;</OrgID>
    <UserID>&#123;D7D30B55-5D9C-DA11-85C9-0013208EF692&#125;</UserID>
    <CRMVersion>4.0.7333.3</CRMVersion>
  </ServerInformation>
</CrmScriptErrorReport>


MarkyMark_netAsked:
Who is Participating?
 
Brett_RatteyConnect With a Mentor Commented:

Problem seems to be that the opportunityproduct is trying to save before you have entered a pricelist.

The pricelist filed has a script that when you remove the field from the form is removed.. so even if you put the field back on the form the script doesnt come back..

good news is there is a solution...
http://dmcrm.blogspot.com/2008_03_01_archive.html

if this is not the cause:
then  check:

that you dont have any Jscript on your opportunityproduct onload event to save the form.

crmForm.Save();

If you do for some reason need to save the opportunityproduct form onload... you can set the pricelist to a default price list  before you call the save function..

if ((crmForm.all.pricelevelid != null) &&(crmForm.all.pricelevelid.DataValue == null))
{
var priceList = crmForm.all.pricelevelid;
var Items = new Array();
Items[0] = newLookupControlItem("<insert Guid for your default pricelist>",1022, "Standard");
priceList.DataValue = Items;
}

if that is not the issue.
check:
if you have any plugins registered for either entities. buggy plugins can sometimes cause these error..





0
 
WilyGuyCommented:
If you turn on Dev Errors, what is the error when you close the opportunity window?
0
 
WilyGuyCommented:
Are there any OnLoad events for the form, or OnChange events for any of the fields?
0
 
Brett_RatteyCommented:
sorry pricelist is on opportunity not opportunityproduct ignore the second scenario..(not on a network with a crm installation at the moment  so couldnt check :S) ...  although you could still use the jscript to set the pricelist on the opportunity onload or onsave event.
0
 
MarkyMark_netAuthor Commented:
I found that there were two issues with my setup.

Firstly, someone had removed the Price List field from the Opportunity form. I put the Price List field back on the form, unfortunately, the code that checked the Price List field had been filled in correctly has also been removed, which is why here was an Error on page message.

With the help of this http://dmcrm.blogspot.com/2008/03/removing-price-list-field-from.html I was able to export the Opportunity entity, add the code back in and re-import the customisation.

Although this didn't allow me to add a product, now when I added a product, an alert would now pop up and let me know that the Price List needed to be set (even though it had).

I was also getting help from Microsoft, they then suggested that I turned off the OnLoad scrpt for the Opportunity form and try adding a Product.

This worked, so I then turned the OnLoad script back on, removed all the If statements from the script and started adding them one at a time to find out which one was causing the problem. After adding all the If statements, I was not able to re-create the problem.

It's working now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.