I have a simple piece of javascript that worked perfectly under CRM 2011, but I cannot seem to get it to work under CRM 2013.
Basically I have a reject button that does the following:
Xrm.Page.data.save(); //executes a SetStateRequest using an http request (synchronously) to complete the activity and set a specific status reason
var success = SetState();
if(success==true)
{
Xrm.Page.ui.close();
}
else
{
Alert(error);
}
In the event of an error, the error is displayed without issue, but when successful I get an error from CRM on the close saying that "Your changes have not been saved. To stay on the page so that you can save your changes, click Cancel". If you then click cancel, you get an error saying that the object cannot be updated because it is read only (which it is since it is completed). I have tried everything I can think of including adding a call to Xrm.Page.data.refresh(), but this also gives the error saying changes have not been saved. Since I have jsut saved the form, I assume that it is the state change that is causing the error, but I cannot figure out a way around it.
Any help would be appreciated.