Answered by:
Javascript generates Unhandled Exception

Question
-
Hi,
I'm investigating an issue with the revise quote function of an active quote.
Had the error in RU11 and also in RU13.
It always throws an Unhandled Exception : The entity cannot be updated because it is read-only
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The entity cannot be updated because it is read-only.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220946</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>The entity cannot be updated because it is read-only.</Message>
<Timestamp>2013-04-05T17:52:27.4147153Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
There is a javascript that loads on Form Load. If I disable it, the error does not produce.
If I put debugger; on the first line, it first throws the error and only then hits the breakpoint.
And the error is only thrown when the page reloads, so it's after the revise itself and it should be editeable.
function SetQouteDataOnCreate() {
debugger;
var FORM_TYPE_CREATE = 1;
var FORM_TYPE_QUICK_CREATE = 5;
//Only when Creating a qoute and accountId is filled in
if (Xrm.Page.ui.getFormType() == FORM_TYPE_CREATE | Xrm.Page.ui.getFormType() == FORM_TYPE_QUICK_CREATE) {........
Any Idea's?
Regards,
Sven Peeters
- Edited by Sven Peeters ( Prodware ) Friday, April 5, 2013 6:33 PM
Friday, April 5, 2013 5:59 PM
Answers
-
Hi,
Finally solved it by adding a check of statecode field in my function.
It did try to change values when I open the active quote, but only gave the error message when you try to revise it.
Regards,
Sven Peeters
- Marked as answer by Sven Peeters ( Prodware ) Monday, April 8, 2013 6:15 AM
Monday, April 8, 2013 6:15 AM
All replies
-
Well I don't see why it would say that an entity can't be updated; but one that does pop out to me is that you're piping what I'm assuming is meant to be a simple OR statement. Is there anyway that you can find out exactly on which line it throws the error?
Friday, April 5, 2013 6:55 PM -
Hi Bmckie,
The error is thrown before it hits the debugger breakpoint, so I have no idea ...
What do you mean with piping in JScript?
Regards,
Sven
Friday, April 5, 2013 6:57 PM -
When you're checking the FormType, you're using a bitwise OR, instead of using '|' try '||'.
Could you explain what the goal of your function is? Like what exactly you're trying update or insert when the javascript finishes.
Friday, April 5, 2013 7:05 PM -
Hi Bmckie,
It execute my code until after I've received the error message, so I don't think it's involved.
Anyway, the code that is within the if clause is to initialize some fields when a new quote has been created.
Regards,
Sven
Friday, April 5, 2013 7:08 PM -
Hi,
Finally solved it by adding a check of statecode field in my function.
It did try to change values when I open the active quote, but only gave the error message when you try to revise it.
Regards,
Sven Peeters
- Marked as answer by Sven Peeters ( Prodware ) Monday, April 8, 2013 6:15 AM
Monday, April 8, 2013 6:15 AM